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学习笔记的更多相关文章

  1. Laravel5.1学习笔记18 数据库4 数据填充

    简介 编写数据填充类 使用模型工厂类 调用额外填充类 执行填充 #简介 Laravel includes a simple method of seeding your database with t ...

  2. Laravel5.5学习笔记

    安装composer 下载安装脚本 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php ...

  3. Laravel5.1学习笔记23 Eloquent 序列化

    Eloquent: Serialization Introduction Basic Usage Hiding Attributes From JSON Appending Values To JSO ...

  4. Laravel5.1学习笔记22 Eloquent 调整修改

    Eloquent: Mutators Introduction Accessors & Mutators Date Mutators Attribute Casting Introductio ...

  5. Laravel5.1学习笔记21 EloquentORM 集合

    Eloquent: Collections Introduction Available Methods Custom Collections Introduction All multi-resul ...

  6. Laravel5.1学习笔记20 EloquentORM 关系

    Eloquent: Relationships Introduction Defining Relationships One To One One To Many Many To Many Has ...

  7. Laravel5.1学习笔记19 EloquentORM 入门

    Eloquent:入门 简介 定义模型(model) Eloquent 模型规范 取出多个模型 取出单个模型 / 集合 取出集合 插入更新模型  基本插入 基本更新 大批量赋值 删除模型 软删除 查询 ...

  8. Laravel5.1学习笔记17 数据库3 数据迁移

    介绍 建立迁移文件 迁移文件结构 执行迁移 回滚迁移 填写迁移文件  创建表 重命名/ 删除表 创建字段 修改字段 删除字段 建立索引 删除索引 外键约束 #介绍 Migrations are lik ...

  9. Laravel5.1学习笔记16 数据库2 查询构造器(这个不用看,不如用EloquentORM)

    Introduction Retrieving Results Aggregates Selects Joins Unions Where Clauses Advanced Where Clauses ...

随机推荐

  1. Miller_Rabin素数测试【学习笔记】

    引语:在数论中,对于素数的研究一直就很多,素数测试的方法也是非常多,如埃式筛法,6N±1法,或者直接暴力判(试除法).但是如果要判断比较大的数是否为素数,那么传统的试除法和筛法都不再适用.所以我们需要 ...

  2. C. Enlarge GCD Codeforces Round #511 (Div. 2)【数学】

    题目: Mr. F has nn positive integers, a1,a2,…,an. He thinks the greatest common divisor of these integ ...

  3. Linux 安装 python3

    1. 安装依赖环境 # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline- ...

  4. indexOf获取字符位置

    先定义一个字符串: var aString = "you are beautiful,so beautiful,and i love you ver much"; 拿到第一个逗号的 ...

  5. DictionaryHelper2

    /// <summary> /// DictionaryHelper /// </summary> public static class DictionaryHelper { ...

  6. 剑指offer——面试题11:快速排序

    #include"iostream" #include"random" using namespace std; /* void Swap(int &a ...

  7. aoj0033

    一.题意:有十个数,判断是否能分成两个递增序列 二.思路: 1.dfs:每个数判断在左边或者右边,遍历所有情况. 2.贪心:在保证递增序的前提下,判断一个数放左边或者右边,决定于其更接近于哪一边最上面 ...

  8. c#项目后期生成事件命令行常用命令

    1.   xcopy (复制文件) xcopy参数介绍 命令格式:XCOPY source [destination] 一堆可选的参数 参数介绍 source 指定要复制的文件. destinatio ...

  9. PIE SDK正射校正

    1. 算法功能简介 正射校正是对影像空间和几何畸变进行校正生成多中心投影平面正射图像的处理过程.它除了能纠正一般系统因素产生的几何畸变外,还可以消除地形引起的几何畸变 PIE支持算法功能的执行,下面对 ...

  10. vi命令——修改文件内容

    以下内容转载自http://blog.csdn.net/bruce0532/article/details/7842384 vi编辑器是所有Unix及Linux系统下标准的编辑器,介绍一下它的用法和一 ...