laravel5.4学习笔记
1、安装laravel可以直接用composer安装,然后用laravel new xxx来新建项目
服务器上安装了composer(php包管理工具)以后,
composer global require "laravel/installer=~1.1"
export PATH=$PATH:/root/.composer/vendor/bin/
然后就可以使用命令
laravel new xxx
2、配置优雅链接,这样定义路由的时候就可以访问到了
在location里面多加一条
location / {
try_files $uri $uri/ /index.php?$query_string;
}
这里端口定义路径要定义到public
/blog/public
3、自动化测试
php vendor/bin/phpunit --bootstrap /ecmoban2/blog/bootstrap/autoload.php /ecmoban2/blog/tests/Feature/ExampleTest.php
或者
phpunit --bootstrap /ecmoban2/blog/bootstrap/autoload.php /ecmoban2/blog/tests/Feature/ExampleTest.php
4、artisan使用
查看可以自动生成的类
php artisan list make
比如我们创建一个Article控制器
php artisan make:controller ArticleController
还可以创建很多东西......
5、视图view使用规则
return view('articles.lists');
如上代表返回了一个视图,视图路径如下,如articles目录不存在,手动创建之,此方法view函数专用
resources/views/articles/lists.blade.php
6、路由Route规则
上面代表访问了xxx.com/user后得到的效果,里面预定义了$name变量的值
Route::get('user/{name?}', function ($name = 'JellyBool') { return 'Hello '.$name; });
查看路由列表
php artisan route:list
更多请看这里
https://www.laravist.com/blog/post/programming-with-laravel-5-blade-views-with-var
or
http://d.laravel-china.org/docs/5.4/lifecycle
7、使用migrate创建mysql数据表
创建一个migration
php artisan make:migration create_articles_table --create='articles'
这个migrate在路径database/migrations/下面
然后在creat方法里面填好字段内容
接着执行命令创建数据表
php artisan migrate
如果想改字段,先执行命令
php artisan migrate:rollback
接着修改完表字段后,执行命令
php artisan migrate
8、修改配置文件时区,包括框架时区和数据库的时区
APP_TIMEZONE=PRC
DB_TIMEZONE=+08:00
9、有时候我们需要引入一些包Package,比如现在我们引入一个官方的html包,执行命令
composer require illuminate/html
10、blade模板里面显示变量
直接显示变量值
{{ $xxx }}
php解析变量后显示,比如html语句
{!! $xxx !!}
laravel5.4学习笔记的更多相关文章
- Laravel5.1学习笔记18 数据库4 数据填充
简介 编写数据填充类 使用模型工厂类 调用额外填充类 执行填充 #简介 Laravel includes a simple method of seeding your database with t ...
- Laravel5.5学习笔记
安装composer 下载安装脚本 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php ...
- Laravel5.1学习笔记23 Eloquent 序列化
Eloquent: Serialization Introduction Basic Usage Hiding Attributes From JSON Appending Values To JSO ...
- Laravel5.1学习笔记22 Eloquent 调整修改
Eloquent: Mutators Introduction Accessors & Mutators Date Mutators Attribute Casting Introductio ...
- Laravel5.1学习笔记21 EloquentORM 集合
Eloquent: Collections Introduction Available Methods Custom Collections Introduction All multi-resul ...
- Laravel5.1学习笔记20 EloquentORM 关系
Eloquent: Relationships Introduction Defining Relationships One To One One To Many Many To Many Has ...
- Laravel5.1学习笔记19 EloquentORM 入门
Eloquent:入门 简介 定义模型(model) Eloquent 模型规范 取出多个模型 取出单个模型 / 集合 取出集合 插入更新模型 基本插入 基本更新 大批量赋值 删除模型 软删除 查询 ...
- Laravel5.1学习笔记17 数据库3 数据迁移
介绍 建立迁移文件 迁移文件结构 执行迁移 回滚迁移 填写迁移文件 创建表 重命名/ 删除表 创建字段 修改字段 删除字段 建立索引 删除索引 外键约束 #介绍 Migrations are lik ...
- Laravel5.1学习笔记16 数据库2 查询构造器(这个不用看,不如用EloquentORM)
Introduction Retrieving Results Aggregates Selects Joins Unions Where Clauses Advanced Where Clauses ...
随机推荐
- Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现
一. Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现 漏洞描述: Home Web Server允许调用CGI程序来通过P ...
- 超文本传送协议 HTTP
超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准. HTTP是一个属于应用层的面向对象的协议, ...
- input type=checkbox的值后台怎么接受
input type=checkbox的值是on或off 实体类中这样写即可 public void setChapterVisibility(Object chapterVisibility) { ...
- ansible 入门学习(一)
一,ansible 目录结构 (来自于ansible权威指南) 二,ansible.cfg 配置项说明 /etc/ansible/ansible.cfg --> ———————————————— ...
- (转)Linux curl命令参数详解
Linux curl命令参数详解 命令:curl在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具.它支持文件的上传和下载,是综合传输工具, ...
- 安装Drupal
我在虚拟机里面安装了Ubuntu Server 14.参考https://www.digitalocean.com/community/tutorials/how-to-install-drupal- ...
- Android代码中实现WAP方式联网
无论是移动.联通还是电信,都至少提供了两种类型的的APN:WAP方式和NET方式.其中NET方式跟WIFI方式一样,无需任何设置,可自由访问所有类型网站,而WAP方式,需要手机先设置代理服务器和端口号 ...
- lua输入函数名字符串执行函数
str = "testA()"loadstring(str)() function testA() ------end 使用loadstring即可执行后面在xlua用了下发现不能 ...
- URAL 1252 ——Sorting the Tombstones——————【gcd的应用】
Sorting the Tombstones Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I ...
- e.target和e.event和event.srcElement
e.target 是目标对象,e.event是目标所发生的事件,event.srcElement捕获当前事件作用的对象 1. $(function(){ $("li:has(ul)" ...