Ale Mohamad
#LaravelBA
github.com/alemohamad
@alemohamad
alemohamad.com
$ php artisan list
$ php artisan migrate --env=local
$ php artisan --version
$ php artisan generate:migration create_posts_table
$ php artisan generate:model Post
$ php artisan generate:pivot orders users
@jeffrey_way
$ php artisan command:make ExampleCommand --command=alemohamad:example
$ php artisan make:console ExampleCommand --command=alemohamad:example
Laravel 4
Laravel 5
A resaltar: El "Command" es una convención a utilizar.
* ¿Se dieron cuenta que podemos usar un comando de Artisan para crear un comando de Artisan?
app/commands
app/Console/Commands
Laravel 4
Laravel 5
<?php
// app/start/artisan.php
Artisan::add(new ExampleCommand);
<?php
// app/Console/Kernel.php
protected $commands = [
'App\Console\Commands\ExampleCommand'
];
Laravel 4
Laravel 5
$this->call('alemohamad:example', array('argument' => 'foo', '--option' => 'bar'));
$this->call('alemohamad:example', ['argument' => 'foo', '--option' => 'bar']);
Laravel 4
Laravel 5
<?php
$this->info('Mostramos un mensaje normal.');
$this->comment('O un comentario.');
$this->error('Y hasta resaltar errores!');
// Y también podemos preguntarle cosas:
$name = $this->ask('Cuál es tu nombre?');
$password = $this->secret('Cuál es tu contraseña?');
if ($this->confirm('Es correcto todo lo que te pregunté? [yes|no]', true)) {
//
}