laravel学习随记1
来源:互联网 发布:stereonet软件 编辑:程序博客网 时间:2024/05/23 13:59
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()方法的作用
0 0
- laravel学习随记1
- laravel学习随记--视图部分(2)
- laravel随记(3)
- JAVA学习随记1
- php学习随记1
- 学习opencv随记1
- laravel学习笔记1
- laravel学习-1
- laravel 学习笔记1
- laravel学习1
- 学习随记
- 学习随记
- 学习随记
- 学习随记
- 学习随记
- 学习随记
- 学习随记
- Android 学习随记笔记(1)
- oracle查看和修改最大连接数
- attribute 的名字重复的问题
- 判断网络状态
- 深度学习系列文章之一:电脑配置选择
- 文档化说明的重要性
- laravel学习随记1
- 图的广度优先搜索(采用邻接表存储方式)
- CityMaker学习教程10 示例代码的使用Javascript
- Struts2找不到action报404错总结,3个解决方法
- 二、C++ 访问类的成员函数和成员变量的三种方法
- Java类与对象的理解
- hihocoder 1257 扩展欧几里得
- 数据库乱码问题
- 【Leetcode】Factorial Trailing Zeroes