jumilla / laravel-extension
Laravel Extension Pack
Installs: 511
Dependents: 0
Suggesters: 0
Security: 0
Stars: 55
Watchers: 7
Forks: 5
Open Issues: 1
Type:framework-extension
Requires
- php: ^7.0
- jumilla/laravel-addomnipot: ^2.0
- jumilla/laravel-source-generator: ^1.3
- jumilla/laravel-versionia: ^2.0
- laravel/framework: ^5.5
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ^6.0
- dev-master
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.8.2
- 3.8.1
- 3.8.0
- 3.7.1
- 3.7.0
- 3.6.2
- 3.6.1
- 3.6.0
- v3.5.4
- v3.5.3
- v3.5.2
- v3.5.1
- v3.5.0
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.5.1
- v2.5.0
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3
- v2.2
- v2.1
- v2.0
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2
- v1.1
- v1.0
- dev-develop
- dev-laravel4
This package is not auto-updated.
Last update: 2024-11-23 17:07:31 UTC
README
Features
-
Additional version-based migration features
- It adopted a semantic version based database migration library. Laravel Versionia has been included.
- Migration & seed class, have been incorporated into the directory structure of Laravel 5.
- You can now specify a group to migration.
- Now the name is attached to the seed.
- Designation of the version, in the class
App/Providers/DatabaseServiceProvider
. - You can use as is the migration & seed class of Laravel.
-
Additional add-on features
- It is a package feature in the application. You can use the image to replicate the directory structure of Laravel 5.
- By default, it will be placed under the 'addons' directory.
- You can make one have its own name space (PSR-4) to add-on.
- It can serve as a package of Laravel 5. Valid namespace notation
{addon-name}::
can be used 'lang', 'view'. Also can use 'config'. - Only additional add-on to copy the directory. You do not need to add code to the configuration file, such as 'config/app.php'.
- 7 types of stationery and offers two types of sample. Can be generated by artisan command
php artisan make:addon
.
-
Commands of file generation
- The class of Laravel 5 that can be generated from the command line, such as Console command, Job, Provider, ...
- The generator command can also be used a customized stub file.
- Compliance with Laravel 5 command of
make:xxx
. Command names and options are the same. - In
--addon
option, you can also generate a file in the add-on.
-
Solution of a facade problem in the namespace
- A facade can be used in the class with a name space under the app directory. (A backslash and a use declaration, unnecessary)
- A facade can also be handled by the same description method from the inside in add-on name space.
How to install
[A] The Laravel project which is already included is downloaded.
composer create-project laravel-plus/laravel5 <project-name>
[B] It's installed in a project of existence.
1. Add the package laravel-plus/extension
use Composer.
Use composer.
composer require laravel-plus/extension
2. Add/Remove the service provider.
Edit file config/app.php
.
- Add
LaravelPlus\Extension\ServiceProvider::class
inproviders
section. - Remove line includes
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class
inproviders
section.
'providers' => [ Illuminate\View\ViewServiceProvider:class, ... // Add the folloing line. LaravelPlus\Extension\ServiceProvider::class, ],
'providers' => [ // Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, ],
Check for running
Add-on wiki
is made as a example.
php artisan make:addon wiki sample:ui
Please confirm the routing setting.
php artisan route:list
A local server is started and accesses http://localhost:8000/addons/wiki
by a browser.
When a package name is indicated, it's success.
php artisan serve
Commands
database:status
Migration, seed's definition and installation state are indicated.
php artisan database:status
database:upgrade
up()
method in migration of all groups, it's carried out and it's made a newest version.
php artisan database:upgrade
It's possible to make them seed after my gray-tion.
php artisan database:upgrade --seed <seed>
database:clean
down()
method in migration of all groups, , it's carried out and it's returned in the clean state.
php artisan database:clean
database:refresh
Re-run migration of all groups.
After database:clean
and database:upgrade
were carried out, same.
php artisan database:refresh
It's possible to make them seed after migration.
php artisan database:refresh --seed <seed>
database:rollback
The version of the specified group is returned one.
php artisan database:rollback <group>
When --all
option is put, everything's version of the designation group is eliminated.
php artisan database:rollback <group> --all
database:again
A newest version of a specified group is made.
I have the same effect as the time when database:rollback <group>
and database:upgrade
were carried out.
php artisan database:again <group>
It's possible to make them seed after migration.
php artisan database:again <group> --seed <seed>
database:seed
Run specified seed.
php artisan database:seed <seed>
When omitting <seed>
, run default seed.
php artisan database:seed
addon:status
Can check the status of addons.
php artisan addon:status
When addons
directory and config/addon.php
file don't exist, it's made.
addon:name
A file in the add-on is scanned and the PHP namespace is changed.
php artisan addon:name blog Wonderful/Blog
When you'd like to confirm the scanned file, please designate -v
option.
php artisan addon:name blog Sugoi/Blog -v
addon:remove
An add-on is eliminated.
php artisan addon:remove blog;
addons/blog
A directory is just eliminated.
make:addon
An add-on is made.
I add on the next command blog
is generated as PHP name spatial Blog
using a form of ui
-type.
php artisan make:addon blog ui
A skeleton can be chosen from 9 kinds.
- minimum - Minimum structure.
- simple - The simple structure with the directory views and the file route.php.
- library - The composition to which a PHP range and a database are offered.
- api - The structure for API.
- ui - Full-set including UI.
- debug - The add-on in which program testing facility is put. Service provider registration of 'debug-bar' is also included.
- generator - Customized for stub files.
- laravel5 - The directory structure of Laravel 5.
- sample:ui - Example of a UI add-on.
- sample:auth - The authentication sample included in Laravel 5.
When not designating a form by a command argument, it can be chosen by an interactive mode.
php artisan make:addon blog
PHP namespace can designate --namespace
by an option.
Please use \\
or /
for a namespace separate.
php artisan make:addon blog --namespace App\\Blog
php artisan make:addon blog --namespace App/Blog
make:console
Generate a class of artisan command.
If you specify foo
to name, to generate a file app/Console/Commands/Foo.php
.
$ php artisan make:console foo
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Commands/Foo.php
.
$ php artisan make:console foo --addon=blog
make:controller
Generate a class of controller.
If you specify FooController
to name, to generate a file app/Http/Controllers/FooController.php
.
$ php artisan make:controller FooController
If you specify option --resource
, to generate a resource controller.
$ php artisan make:controller FooController --resource
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Controllers/FooController.php
.
$ php artisan make:controller FooController --addon=blog
make:event
Generate a class of event.
If you specify FooEvent
to name, to generate a file app/Events/FooEvent.php
.
$ php artisan make:event FooEvent
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Events/FooEvent.php
.
$ php artisan make:event FooEvent --addon=blog
make:job
Generate a class of job.
If you specify a FooJob
to name, to generate a file app/Jobs/FooEvent.php
.
$ php artisan make:job FooJob
If you specify option --queued
, to generate a job class implemented ShouldQueue
interface.
$ php artisan make:job FooJob --queued
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Jobs/FooJob.php
.
$ php artisan make:job FooJob --addon=blog
If using a App/Commands
directory of Laravel 5.0, app/Commands/FooCommand.php
can also be generated.
$ php artisan make:job /Commands/FooCommand
make:listener
Generate a class of listener.
If you specify FooListener
to name, to generate a file app/Listeners/FooListener.php
.
Require --event
option.
$ php artisan make:listener FooListener --event=bar
If you specify option --queued
, to generate a job class implemented ShouldQueue
interface.
$ php artisan make:listener FooListener --event=bar --queued
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Listeners/FooListener.php
.
$ php artisan make:listener FooListener --event=bar --addon=blog
make:middleware
Generate a class of middleware.
If you specify foo
to name, to generate a file app/Http/Middleware/Foo.php
.
$ php artisan make:middleware foo
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Middleware/Foo.php
.
$ php artisan make:middleware foo --addon=blog
make:migration
Generate a class of migration.
If you specify foo
to name, to generate a file app/Database/Migrations/App_1_0.php
.
$ php artisan make:migration App_1_0
If you specify materials
to option --create
, to generate a migration class for create materials table.
$ php artisan make:migration App_1_1 --create=materials
If you specify materials
to option --update
, to generate a migration class for update materials table.
$ php artisan make:migration App_1_2 --update=materials
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Migrations/Blog_1_0.php
.
$ php artisan make:migration Blog_1_0 --addon=blog
make:model
Generate a class of Eloquent model.
If you specify foo
to name, to generate a file app/Foo.php
related to foos table.
$ php artisan make:model foo
If you specify services/models/foo
to name, to generate a file app/Services/Models/Foo.php
related to foos table.
PHP namespace will be App\Services\Models
.
$ php artisan make:model services/models/foo
If you specify App_1_1
to option --migration
, also generates together migration file.
This is the same as a result of executing the command php artisan make:migration App_1_1 --create=foos
.
$ php artisan make:model foo --migration=App_1_1
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Foo.php
.
$ php artisan make:model foo --addon=blog
make:policy
Generate a class of policy.
If you specify foo
to name, to generate a file app/Policies/Foo.php
.
$ php artisan make:policy foo
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Policies/Foo.php
.
$ php artisan make:policy foo --addon=blog
make:provider
Generate a class of service provider.
If you specify FooServiceProvider
to name, to generate a file app/Providers/FooServiceProvider.php
.
$ php artisan make:provider FooServiceProvider
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Providers/FooServiceProvider.php
.
$ php artisan make:provider FooServiceProvider --addon=blog
make:request
Generate a class of form request.
If you specify FooRequest
to name, to generate a file app/Http/Requests/FooRequest.php
.
$ php artisan make:request FooRequest
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Requests/FooRequest.php
.
$ php artisan make:request FooRequest --addon=blog
make:seeder
Generate a class of seeder.
If you specify staging
to name, to generate a file app/Database/Seeds/Staging.php
.
$ php artisan make:request staging
If you specify blog
to option --addon
, to generate a file addons/blog/classes/Seeds/Staging.php
.
$ php artisan make:request staging --addon=blog
make:test
Generate a class of PHPUnit test suite.
If you specify FooTests
to name, to generate a file tests/FooTests.php
.
$ php artisan make:test FooTests
If you specify blog
to option --addon
, to generate a file addons/blog/tests/FooTests.php
.
$ php artisan make:test FooTests --addon=blog
Helper functions
addon($name = null)
Get the add-on by name.
$addon = addon('blog');
If omit the name, it returns the add-on that contains the calling class.
This is equivalent to a addon(addon_name())
.
namespace Blog\Http\Controllers; class BlogController { public function index() { $addon = addon(); // == addon(addon_name()) Assert::same('blog', $addon->name()); } }
object retrieved by the addon()
function, you can access the add-on attributes and resources.
$addon = addon(); $addon->path(); // {$root}/addons/blog $addon->relativePath(); // addons/blog $addon->phpNamespace(); // Blog $addon->config('page.row_limit', 20); $addon->trans('emails.title'); $addon->transChoice('emails.title', 2); $addon->view('layouts.default'); $addon->spec('forms.user_register');
addon_name($class)
Get the add-on name from the class name . The class name must be a fully qualified name that contains the name space. Get the add-on by name.
$name = addon_name(get_class($this)); $name = addon_name(\Blog\Providers\AddonServiceProvider::class); // 'blog'
If you omit the argument, returns the name of the add-on contains the caller of the class.
<?php namespace Blog\Controllers; class PostsController { public function index() { $name = addon_name(); // 'blog' } }
Facade expansion
Facade of Laravel converts the static method call of class to an instance method invocation, and has been achieved by creating an alias for the facade class in the global namespace.
For Laravel 5 alias loader does not act only in the global name space , to handle the facade from the name space (such as App
) it must put \
to the class name prefix.
function index()
{
return \View::make()
}
Or a use declaration is used.
use View;
...
function index()
{
return View::make()
}
Laravel Extension has the alias loader which settles a facade in the namespace in the add-on bottom, so a way of Laravel 4.2 formula document mentioning can be used just as it is.
function index()
{
return View::make()
}
Bootstrap behavior
- Require
files
entry in fileaddons/{addon-name}/addon.json
. - Sees
namespace
entry in fileaddons/{addon-name}/addon.php
and establishes class automatic threading based on PSR-4 agreement to all directories specified asdirectories
.
Author
古川 文生 / Fumio Furukawa (fumio@jumilla.me)
License
MIT