1,laravel的配置
a,php>=5.5.9版本
b,在Apache的配置文件下开启rewrite和vhost(有两个其中有个虚拟机的vhost)
还有<Directory>
AllowOverride all
Require all granted
</Directory>
httpd-vhost.conf这个文件配置下项目的虚拟环境
c,开启PHP扩展
php.ini:\wamp\bin\php\php5.5.12\php.ini
extension=php_openssl.dll
extension=php_mbstring.dll
extension=php_pdo_mysql.dll
d,注意:
运行Laravel启动欢迎页
d1、使用下载安装方法安装laravel5.2,需要重新生成key
php artisan key:generate
d2、修改默认首页、伪静态配置文件
2,参考文档
中文:http://laravelacademy.org/laravel-docs-5_2
英文:https://laravel.com/docs/5.2
3,命名路由 as => 'routename'
Route::get('test',['as' => 'profile','
user'=>'Admin\IndexController@index']);
另外一种命名路由方法:
Route::get('test','Admin\UserController@index)->name('profile');
4,路由的分组
例子:Route::get('admin\login',Admin\IndexController@login);
Route::get('admin\index',Admin\IndexController@index);
用法:按照前缀分组
Route::group(['profile'=>'admin'],function(){
Route::get('login','Admin\IndexController@login');
Route::get('index','Admin\IndexController@index');
});
Route::group(['profile'=>'admin','namespace'=>'Admin'],function(){
Route::get('login','IndexController@login');
Route::get('index','IndexController@index');
});
4,资源路由
Route::resource('article','ArticleController');
5,中间件 Middleware
注意:需要使用web中间件才能使用session的
Route::group(['middleware'=>['web']],function(){
Route::get('/',function(){
session(['key'=>123]);
return view('welcome);
});
Route::get('/test',function(){
echo session('key');
return 'test';
})
})
中间件的定义在 Requests文件夹中Kenerl.php文件中;
使用中间件的时候可以在Kernel.php文件中
清除session值: session(['admin'=>null]);
6,模板试图
with() : 分配数据
view('my_view')->whith('name',$name);
view('my_view',compact('data','title'));
compact('data,title'); 意思是同时分配这两个数组和参数 compact()方法的作用
a,php>=5.5.9版本
b,在Apache的配置文件下开启rewrite和vhost(有两个其中有个虚拟机的vhost)
还有<Directory>
AllowOverride all
Require all granted
</Directory>
httpd-vhost.conf这个文件配置下项目的虚拟环境
c,开启PHP扩展
php.ini:\wamp\bin\php\php5.5.12\php.ini
extension=php_openssl.dll
extension=php_mbstring.dll
extension=php_pdo_mysql.dll
d,注意:
运行Laravel启动欢迎页
d1、使用下载安装方法安装laravel5.2,需要重新生成key
php artisan key:generate
d2、修改默认首页、伪静态配置文件
2,参考文档
中文:http://laravelacademy.org/laravel-docs-5_2
英文:https://laravel.com/docs/5.2
3,命名路由 as => 'routename'
Route::get('test',['as' => 'profile','
user'=>'Admin\IndexController@index']);
另外一种命名路由方法:
Route::get('test','Admin\UserController@index)->name('profile');
4,路由的分组
例子:Route::get('admin\login',Admin\IndexController@login);
Route::get('admin\index',Admin\IndexController@index);
用法:按照前缀分组
Route::group(['profile'=>'admin'],function(){
Route::get('login','Admin\IndexController@login');
Route::get('index','Admin\IndexController@index');
});
Route::group(['profile'=>'admin','namespace'=>'Admin'],function(){
Route::get('login','IndexController@login');
Route::get('index','IndexController@index');
});
4,资源路由
Route::resource('article','ArticleController');
5,中间件 Middleware
注意:需要使用web中间件才能使用session的
Route::group(['middleware'=>['web']],function(){
Route::get('/',function(){
session(['key'=>123]);
return view('welcome);
});
Route::get('/test',function(){
echo session('key');
return 'test';
})
})
中间件的定义在 Requests文件夹中Kenerl.php文件中;
使用中间件的时候可以在Kernel.php文件中
清除session值: session(['admin'=>null]);
6,模板试图
with() : 分配数据
view('my_view')->whith('name',$name);
view('my_view',compact('data','title'));
compact('data,title'); 意思是同时分配这两个数组和参数 compact()方法的作用