How to load a language file in all locales in Laravel (COMMON.PHP)?
/resources
/lang
/en
test.php
/fa
test.php
/fr
test.php
/COMMON.php
In resources/lang/ , make the language abbreviation name folder and put your language file there.
Related
Is there a way to get the application name or print root folder name in a view in CodeIgniter?
Actually, I want to print the application in multiple views in CodeIgniter 3.
I tried with base URL but is not a perfect solution when you are using a framework.
FCPATH -> '/'
BASEPATH -> '/system/'
APPPATH -> '/application/'
APPPATH is your application folder
echo APPPATH;
if you need the root path then FCPATH.
echo FCPATH;
Following are the build-in constants you can use as per your requirements for getting the paths in Codeigniter:
EXT: The PHP file extension
FCPATH: Path to the front controller (this file) (root of CI)
SELF: The name of THIS file (index.php)
BASEPATH: Path to the system folder
APPPATH: The path to the “application” folder
Note:-
For More info regarding this
https://codeigniter.com/userguide3/general/reserved_names.html?highlight=apppath
Get application name or root folder name I used codeigniter reserved name in a php basename function.
echo FCPATH;
// output: E:\wamp64\www\MyApplicationName\
echo basename(FCPATH);
// output: MyApplicationName
I need to include a php snippet to a few .phtml template files e.g. <?php include("foo.php") ?>:
Where is the common place to add foo.php? Can I just create a folder called "partials" in the root dir or is there already a special place for include files?
show Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php while visiting my CI project
The file mentioned in the message (index.php) is typically located in the root folder of your Codeigniter installation.
The normal files structure for Codeigniter is this.
/root_name (often named 'www' or 'htdocs')
/application
/system
index.php <- Is the file to edit
The section of the index.php where you need to make the adjustment looks like this.
/*
* ---------------------------------------------------------------
* SYSTEM DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "system" directory.
* Set the path if it is not in the same directory as this file.
*/
$system_path = 'system';
If you use the normal installation folder structure then the correct entry is 'system'. If you have moved the 'system' folder to some other location, or renamed it, then the value of $system_path must be adjusted to match the new location or name.
I created folder called en407 and inside it i create a file called assigment that contain html , css and also php.
http://localhost/en407b/
When i click on the assginmnt file , i should let me choose what file to open
http://localhost/en407b/assignment
but the link directly go to my html file which is index.html and the link remains
http://localhost/en407b/assignment
in my assignment file , it contain index.html , index2.html and other....
how to fix it???
At first you can't run PHP in .html files because the server does not recognize it as valid till you tell it to do it. To do this create a .htaccess file in your root web directory and add this line inside it:
AddType application/x-httpd-php .htm .html
This will tell Apache to process files with a .htm or .html file extension as PHP files.
I want to include this file
api/app/PHPexcel/phpexcel.php
Into this library
application/library/excel.php
In codeIgniter. Base url in my config file is empty.
pls help.
On your file try include or require
File-name: application > library > Excel.php
<?php
// dirname will let you access out side application folder.
$file = dirname(FCPATH . '/api/app/PHPexcel/phpexcel.php');
// $file = FCPATH . 'api/app/PHPexcel/phpexcel.php';
require_once $file;
class Excel {
public function __construct() {
}
}
Folder Layout
application
api
api > app
system
index.php
Best not to leave your base_url blank will run into some issues later.
Use absolute path. Something like:
'/var/www/html/api/app/PHPexcel/phpexcel.php'
or
'C:\wamp\www\api\app\PHPexcel\phpexcel.php'
Note that you have some predefined constants in CodeIgniter itself:
APPPATH => '/path/to/application/'
FCPATH => '/path/to/directory/where/index/php/file/is/
etc...
Those constants are defined in index.php file.
Commonly used practice is to put (e.g.) PHPexcel directory into
APPPATH . 'libraries'
location so structure could be
-application
--libraries
---PHPexcel
----phpexcel.php
---Excel.php # don't forget have it with ucfirst rule if CI3
or you can put directory in third_party and include it as
APPPATH . 'third_party/PHPexcel/phpexcel.php';
But it is up to you how do you like to arrange files/directories structure of your app.
In application/config/autoload.php file there is variable named $autoload['libraries'] = array();
you should define your library in this array and your library will be loaded automatically.