We make user difined function to reuse code. To use user difined function you need to follow the steps
given below.
- Make your file in app folder and write your code in that file . In my case file name is helper.php and funtion name is Title . i.e.
function Title()
{
echo "Girfa IT Services";
}
- Goto composer.json file and add the following lines in autoload section.In my case pagelib.php is my file. Write your file name.
"autoload":
{
"files" :["app/pagelib.php"],
},
- Now you can call the function inside of helper.php file , anywhere in your project.
Note : Run given command for update your function
composer dump-autoload
Then, in your hosting site, you can update two files, autoload_classmap.php and autoload_static.php, manually in vendor/composer folder. I prefer to copy and paste the added classes from local to the hosting server
No comments:
Post a Comment