First, expand your own class
Create a directory under app/libraries\class
Then mytest.php class name format hump myTest
Copy Code code as follows:
<?php
Class MyTest
{
Public Function test ()
{
Return ' 1asdasd111 ';
}
}
In app/start/global.php
Copy Code code as follows:
Classloader::adddirectories Array (
App_path (). ' /commands ',
App_path (). ' /controllers ',
App_path (). ' /models ',
App_path (). ' /database/seeds ',
App_path (). ' /libraries/class ',//Increase this section
));
Load with Make
Copy Code code as follows:
<?php
Class HomeController extends Basecontroller {
protected $layout = ' layouts.main ';
Public Function Index ()
{
$a = App::make (' mytest '); Usage
echo $a->test ();
}
}
Second, expand their own functions
Create a directory under app/libraries\function
Establish helper.php
function format, such as function_exists, to prevent duplicate system name
Copy Code code as follows:
if (! function_exists (' test2 '))
{
function Test2 ()
{
Echo 2222222222222222;
}
}
Method One:
In app/filters.php
Copy Code code as follows:
App::before (function ($request)
{
Require App_path (). ' /libraries/function/helper.php '; Load a custom function
});
Method Two:
In app/bootstrap/autolad.php
Copy Code code as follows:
Require __dir__. ' /.. /app/functions.php '; Introducing a Custom Function library
I feel the method will be better in a minute.