友链
导航
These are the good times in your life,
so put on a smile and it'll be alright
友链
导航
Log::
调用,但只有单 facility,Log 级别如下:Log::info('This is some useful information.'); Log::warning('Something could be going wrong.'); Log::error('Something is really going wrong.');
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 $log->addWarning('Foo'); $log->addError('Bar');
$ php artisan generate:resource post --fields="title:string, body:text"
// $ composer require rcrowe/laravel-statsd Statsd::timing($key, $time); Statsd::gauge($key, $value); Statsd::set($key, $value); Statsd::increment($key); Statsd::decrement($key); Statsd::updateCount($key, $delta);
// 记录错误到 php artisan tail Log::error($exception);
Creating default object from empty value
可能是 controller 中有 typo// app/config/database.php 'connections' => array( 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'options' => array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_STRINGIFY_FETCHES => false ) ), ), );
sudo dpkg-reconfigure tzdata
sudo composer self-update
$ sudo vi /etc/php5/cli/php.ini ; Use -1 for unlimited or define an explicit value like 512M memory_limit = -1
可能能快点儿
composer install --no-dev --prefer-dist
composer update new/package 或者 composer require new/package 都不行
https://github.com/JeffreyWay/Laravel-4-Generators#generating-schema
$ 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
generate | $table | Description |
---|---|---|
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": [ "app/commands", $ 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.