This Laravel package provide artisan developers with useful developement commands and helpers that are not included in Laravel by default.
To get the latest version of Laravel Dev Extras, simply require the project using Composer:
$ composer require --dev jim-merioles/laravel-dev-extras
Once installed, you need to register the service provider. Open up config/app.php
and add the following to the providers
key:
/*
* Package Service Providers...
*/
JimMerioles\LaravelDevExtras\LaravelDevExtrasServiceProvider::class,
Generates a repository class for a model.
Most of the time our code screams for a better architecture, and often we want our models to adhere to Repository Design Pattern for some reasons; for better integration with caching and other stuffs.
$ php artisan make:repository FooRepository
<?php
namespace App\Repositories;
class FooRepository
{
/**
* Create a new repository instance.
*
* @return void
*/
public function __construct()
{
//
}
}
Automatic model scaffold within the repository class.
$ php artisan make:repository FooRepository --model=Foo
<?php
namespace App\Repositories;
use Foo;
class FooRepository
{
/**
* Foo model instance.
*
* @var Foo
*/
protected $foo;
/**
* Create a new repository instance.
*
* @param Foo $foo
*/
public function __construct(Foo $foo)
{
$this->foo = $foo;
//
}
}
Alias for:
DB::listen(function ($event) {
dump($event->sql);
dump($event->bindings);
dump($event->time);
});
Most of the time when tinkering with your database and eloquent models using $ php artisan tinker
, you might want to listen for and dump sql queries, bindings and execution time to inspect or even just to verify if your cache works when no query has been made.
Psy Shell v0.7.2 (PHP 7.0.11-1+deb.sury.org~trusty+1 — cli) by Justin Hileman
>>> db() // dumps queries, bindings, and execution time
Very open for suggestions and request. Please request an issue or by pull requests.
If you discover a security vulnerability, please send an e-mail to Jim Merioles at jimwisleymerioles@gmail.com. All security vulnerabilities will be promptly addressed.
Laravel Dev Extras is open-sourced software licensed under the MIT license.