Create a laravel5.1 project easy_grouping.
Composer Create-project Laravel/laravel easy_grouping 5.1.*
1. Multi-language TipsCreate a new directory ZH-CN in the Resources-lang directory, creating tip.php, as follows
<?php return
[' => ' successful operation '];
Modify config/app.php
' Locale ' => ' ZH-CN ',
In the mouth of the answer
Echo Trans (' tip.200 ');
Output "Operation succeeded"
2. Introducing Common functionsCreate a helper directory in the app directory and create a common_functions.php that reads as follows
<?php
function Test ()
{
echo ' common funciton include succeed ';
}
Increase in Composer.json
"AutoLoad": {
"files": [
"app/helper/common_funtions.php"
]
}
Command-line execution
Composer Dump-autoload
The test () function can be used globally.
3.url Ignore CaseUnder the helper folder created above, create a caseinsensitiveurivalidator.php that reads
<?php namespace App\helper;
Use Illuminate\http\request;
Use Illuminate\routing\route;
Use Illuminate\routing\matching\validatorinterface;
Class Caseinsensitiveurivalidator implements Validatorinterface
{public
function matches (Route $route, Request $request)
{
$path = $request->path () = = '/'? '/': '/'. $request->path ();
Return Preg_match (preg_replace ('/$/', ' I ', $route->getcompiled ()->getregex ()), Rawurldecode ($path));
}
Introduced in the routes.php
Use Illuminate\routing\route as Illuminateroute;
Use App\helper\caseinsensitiveurivalidator;
Use Illuminate\routing\matching\urivalidator;
$validators = Illuminateroute::getvalidators ();
$validators [] = new Caseinsensitiveurivalidator;
Illuminateroute:: $validators = Array_filter ($validators, function ($validator) {return
Get_class ($validator)!= Urivalidator::class;
});