Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools



  • lumen 现在还没有模块化的方法 — Xiaopei Li 2015/08/17 04:47
  • creolab/laravel-modules Application specific modules in Laravel 4
  • 方便开发 API 的库:dingo/api A RESTful API package for the Laravel and Lumen frameworks.
  • laravel 封装了 seldaek/monolog,可直接 Log:: 调用,但只有单 facility,Log 级别如下:
    Log::info('This is some useful information.');
    Log::warning('Something could be going wrong.');
    Log::error('Something is really going wrong.');
    • DEBUG (100): Detailed debug information.
    • INFO (200): Interesting events. Examples: User logs in, SQL logs.
    • NOTICE (250): Normal but significant events.
    • WARNING (300): Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
    • ERROR (400): Runtime errors that do not require immediate action but should typically be logged and monitored.
    • CRITICAL (500): Critical conditions. Example: Application component unavailable, unexpected exception.
    • ALERT (550): Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
    • EMERGENCY (600): Emergency: system is unusable.
    • 如果需要高级功能,可直接调用 monolog
      use Monolog\Logger;
      use Monolog\Handler\StreamHandler;
      // create a log channel
      $log = new Logger('name');
      $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
      // add records to the log


  • homestead 默认时区不对,设置上海时区:sudo dpkg-reconfigure tzdata


  • sudo composer self-update
  • 吃内存 PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <…>
    $ sudo vi /etc/php5/cli/php.ini
    ; Use -1 for unlimited or define an explicit value like 512M
    memory_limit = -1
    • composer 真是我见过最烂的包管理系统


composer install --no-dev --prefer-dist
  • composer 就 TMD 没有一种安装一个包但不更新其他包的机制,SO 上说的
    composer update new/package
    composer require new/package



$ php artisan generate:resource post --fields="title:string, body:text"
    --fields="first:string, last:string"
    --fields="age:integer, yob:date"
    --fields="username:string:unique, age:integer:nullable"
    --fields="name:string:default('John Doe'), bio:text:nullable"
    --fields="username:string(30):unique, age:integer:nullable:default(18)"

schema#adding-columns - Laravel Doc

bigIncrements$table->bigIncrements('id');Incrementing ID using a “big integer” equivalent.
bigInteger$table->bigInteger('votes');BIGINT equivalent to the table
binary$table->binary('data');BLOB equivalent to the table
boolean$table->boolean('confirmed');BOOLEAN equivalent to the table
char$table->char('name', 4);CHAR equivalent with a length
date$table->date('created_at');DATE equivalent to the table
dateTime$table->dateTime('created_at');DATETIME equivalent to the table
decimal$table->decimal('amount', 5, 2);DECIMAL equivalent with a precision and scale
double$table->double('column', 15, 8);DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point
enum$table->enum('choices', array('foo', 'bar'));ENUM equivalent to the table
float$table->float('amount');FLOAT equivalent to the table
increments$table->increments('id');Incrementing ID to the table (primary key).
integer$table->integer('votes');INTEGER equivalent to the table
longText$table->longText('description');LONGTEXT equivalent to the table
mediumInteger$table->mediumInteger('numbers');MEDIUMINT equivalent to the table
mediumText$table->mediumText('description');MEDIUMTEXT equivalent to the table
morphs$table->morphs('taggable');Adds INTEGER taggable_id and STRING taggable_type
nullableTimestamps$table->nullableTimestamps();Same as timestamps(), except allows NULLs
smallInteger$table->smallInteger('votes');SMALLINT equivalent to the table
tinyInteger$table->tinyInteger('numbers');TINYINT equivalent to the table
softDeletes$table->softDeletes();Adds deleted_at column for soft deletes
string$table->string('email');VARCHAR equivalent column
string$table->string('name', 100);VARCHAR equivalent with a length
text$table->text('description');TEXT equivalent to the table
time$table->time('sunrise');TIME equivalent to the table
timestamp$table->timestamp('added_on');TIMESTAMP equivalent to the table
timestamps$table->timestamps();Adds created_at and updated_at columns
rememberToken$table->rememberToken();Adds remember_token as VARCHAR(100) NULL
:nullable->nullable()Designate that the column allows NULL values
:default(18)->default($value)Declare a default value for a column
:unsigned->unsigned()Set INTEGER to UNSIGNED


Resource Controllers - Laravel Doc

Verb Path Action Route Name
GET /resource index resource.index
GET /resource/create create resource.create
POST /resource store resource.store
GET /resource/{resource} show resource.show
GET /resource/{resource}/edit edit resource.edit
PUT/PATCH /resource/{resource} update resource.update
DELETE /resource/{resource} destroy resource.destroy



homestead 默认无 phpunit,如下安装:

$ vi composer.json
@@ -7,6 +7,9 @@
        "require": {
                "laravel/framework": "4.2.*"
+       "require-dev": {
+               "phpunit/phpunit": "4.0.*"
+       },
        "autoload": {
                "classmap": [
$ php composer.phar install --dev
$ vendor/bin/phpunit 


For Maximum function nesting level of '100' reached, aborting!, adding xdebug.max_nesting_level=500 to /etc/php5/cli/conf.d/20-xdebug.ini inside Homestead, problem fixed.

it/laravel.txt · Last modified: 2016/02/18 11:26 by admin