如何新增一个laravel包

如何新增一个laravel包

How to create a Laravel 5 package in 10 easy steps

http://laraveldaily.com/how-to-create-a-laravel-5-package-in-10-easy-steps/

1. 在composer.json的autoload->psr-4

"App\\": "app/",

"Laraveldaily\\Timezones\\": "packages/laraveldaily/timezones/src",

2. 

在config/app.php添加providers,把刚才src目录下带ServiceProvider的类都添加进去

Laraveldaily\Timezones\TimezonesServiceProvider::class,


3.

composer dump-autoload

新增的类就该起作用了


4. 如何使用刚才新增的类?

php artisan make:controller DemoController

在DemoController.php里

use Laraveldaily\Timezones\xx;


另外,如何发布共享包?

https://packagist.org/



Package Development

https://laravel.com/docs/5.5/packages



https://laracasts.com/discuss/channels/general-discussion/create-own-service-provider?page=1

你可能感兴趣的:(如何新增一个laravel包)