PHPackages                             laravel-plus/extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. laravel-plus/extension

AbandonedArchivedFramework-extension[Database &amp; ORM](/categories/database)

laravel-plus/extension
======================

Laravel Extension Pack

4.0.3(8y ago)561.8k5[1 issues](https://github.com/jumilla/laravel-extension/issues)2MITPHPPHP ^7.0

Since Jun 12Pushed 8y ago6 watchersCompare

[ Source](https://github.com/jumilla/laravel-extension)[ Packagist](https://packagist.org/packages/laravel-plus/extension)[ Docs](https://laravel.tokyo)[ RSS](/packages/laravel-plus-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (50)Used By (2)

Laravel Extension Pack
======================

[](#laravel-extension-pack)

[![Build Status](https://camo.githubusercontent.com/3d8c68794338264b4660379b6d61f6f4e0b0c4ac1a8a1997e91a75bb8ad8757d/68747470733a2f2f7472617669732d63692e6f72672f6a756d696c6c612f6c61726176656c2d657874656e73696f6e2e737667)](https://travis-ci.org/jumilla/laravel-extension)[![Quality Score](https://camo.githubusercontent.com/3af84ee838b1081d7ef98913f6e1ecd302d93fcb19065042949a2a01b38383ea/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a756d696c6c612f6c61726176656c2d657874656e73696f6e2e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/jumilla/laravel-extension)[![Code Coverage](https://camo.githubusercontent.com/3d86a08968bba1d4b20050730509a22246d9e4180c6632f765de91d0ec5087c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a756d696c6c612f6c61726176656c2d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jumilla/laravel-extension/)[![Latest Stable Version](https://camo.githubusercontent.com/b2297fcd511e05c83ac29d653f1730d652dddf87feab3bbc984b8388cdffe00e/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d706c75732f657874656e73696f6e2f762f737461626c652e737667)](https://packagist.org/packages/laravel-plus/extension)[![Total Downloads](https://camo.githubusercontent.com/ec88b1d0c739306fb22123a9429e13272406180df14ccc72645546e65bd81234/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d706c75732f657874656e73696f6e2f642f746f74616c2e737667)](https://packagist.org/packages/laravel-plus/extension)[![Software License](https://camo.githubusercontent.com/03734bb083e1b52d7fee0d07e3101be06bb74b604eb9e71f33558952eb8cb07c/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d706c75732f657874656e73696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/laravel-plus/extension)

[日本語ドキュメント - Japanese](readme-ja.md)

Features
--------

[](#features)

- Additional version-based migration features

    - It adopted a semantic version based database migration library. [Laravel Versionia](http://github.com/jumilla/laravel-versionia) has been included.
    - Migration &amp; 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 &amp; 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
--------------

[](#how-to-install)

### \[A\] The Laravel project which is already included is downloaded.

[](#a-the-laravel-project-which-is-already-included-is-downloaded)

```
composer create-project laravel-plus/laravel5
```

### \[B\] It's installed in a project of existence.

[](#b-its-installed-in-a-project-of-existence)

#### 1. Add the package `laravel-plus/extension` use Composer.

[](#1-add-the-package-laravel-plusextension-use-composer)

Use composer.

```
composer require laravel-plus/extension
```

#### 2. Add/Remove the service provider.

[](#2-addremove-the-service-provider)

Edit file `config/app.php`.

- Add `LaravelPlus\Extension\ServiceProvider::class` in `providers` section.
- Remove line includes `Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class` in `providers` section.

```
	'providers' => [
		Illuminate\View\ViewServiceProvider:class,
		...
		// Add the folloing line.
		LaravelPlus\Extension\ServiceProvider::class,
	],
```

```
	'providers' => [
		// Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
	],
```

Check for running
-----------------

[](#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
--------

[](#commands)

### `database:status`

[](#databasestatus)

Migration, seed's definition and installation state are indicated.

```
php artisan database:status
```

### `database:upgrade`

[](#databaseupgrade)

`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
```

### `database:clean`

[](#databaseclean)

`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`

[](#databaserefresh)

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
```

### `database:rollback`

[](#databaserollback)

The version of the specified group is returned one.

```
php artisan database:rollback
```

When `--all` option is put, everything's version of the designation group is eliminated.

```
php artisan database:rollback  --all
```

### `database:again`

[](#databaseagain)

A newest version of a specified group is made.

I have the same effect as the time when `database:rollback ` and `database:upgrade` were carried out.

```
php artisan database:again
```

It's possible to make them seed after migration.

```
php artisan database:again  --seed
```

### `database:seed`

[](#databaseseed)

Run specified seed.

```
php artisan database:seed
```

When omitting ``, run default seed.

```
php artisan database:seed
```

### `addon:status`

[](#addonstatus)

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`

[](#addonname)

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`

[](#addonremove)

An add-on is eliminated.

```
php artisan addon:remove blog;
```

`addons/blog` A directory is just eliminated.

### `make:addon`

[](#makeaddon)

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

[](#makeconsole)

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

[](#makecontroller)

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

[](#makeevent)

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

[](#makejob)

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

[](#makelistener)

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

[](#makemiddleware)

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

[](#makemigration)

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

[](#makemodel)

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

[](#makepolicy)

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

[](#makeprovider)

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

[](#makerequest)

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

[](#makeseeder)

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

[](#maketest)

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
----------------

[](#helper-functions)

### addon($name = null)

[](#addonname--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)

[](#addon_nameclass)

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.

```
