kallbuloso/laravel-packager
é um pacote do Laravel que foi criado para gerar e gerenciar pacotes (Packages)
e reutilizálos em sua aplicação Laravel. O laravel-packager
é um pacote suportado e testado no Laravel ^6.*
.
O laravel-packager
é na verdade uma versão ligeiramente modificada de Jeroen-G/laravel-packager. Eu criei a minha própria versão do laravel-packager
porque queria ter controle total sobre como os comandos são gerenciados, e também tenho minhas próprias necessidades quanto ao que preciso que o pacote faça.
Se você achar que Jeroen-G/laravel-packager
atende às suas necessidades melhor do que kallbuloso/laravel-packager
, por qualquer motivo, use essa. Minha versão do pacote é destinada principalmente para as minhas próprias necessidades e não pretende ser um substituto ou concorrente para o outro pacote.
This package provides you with a simple tool to set up a new package and it will let you focus on the development of the package instead of the boilerplate.
Via Composer
$ composer require kallbuloso/laravel-packager --dev
If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php
:
kallbuloso\Packager\PackagerServiceProvider::class,
If you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider.
Be aware that the auto-discovery also means that this package is loaded in your production environment. Therefore you may disable auto-discovery and instead put in your AppServiceProvider
something like this:
if ($this->app->environment('local')) {
$this->app->register('kallbuloso\Packager\PackagerServiceProvider');
}
Optional you can publish the configuration to provide a different service provider stub. The default is here.
$ php artisan vendor:publish --provider="kallbuloso\Packager\PackagerServiceProvider"
Command:
$ php artisan packager:new MyVendor MyPackage
Result:
O comando irá lidar com praticamente tudo para você. Ele criará um diretório de pacotes, cria o fornecedor e o diretório de pacotes, puxa um pacote básico, configura o composer.json e cria um provedor de serviços.
Nota
- após instalar, em
composer.json/repositories
acerte o caminho de onde está repositório emurl
, - abra o terminal no diretório do package criado e digite o seguinte comando;
$ composer dump
- em seguida com o terminal aberto no diretório raíz do projeto digite;
$ composer require MyVendor/MyPackage
Options:
$ php artisan packager:new MyVendor MyPackage --i
$ php artisan packager:new --i
The package will be created interactively, allowing to configure everything in the package's composer.json
, such as the license and package description.
Remarks: The new package will be based on this custom skeleton.
Command:
$ php artisan packager:get https://github.com/author/repository
$ php artisan packager:git https://github.com/author/repository
Result:
This will register the package in the app's composer.json
file.
If the packager:git
command is used, the entire Git repository is cloned. If packager:get
is used, the package will be downloaded, without a repository. This also works with Bitbucket repositories, but you have to provide the flag --host=bitbucket
for the packager:get
command.
Options:
$ php artisan packager:get https://github.com/author/repository --branch=develop
$ php artisan packager:get https://github.com/author/repository MyVendor MyPackage
$ php artisan packager:git https://github.com/author/repository MyVendor MyPackage
It is possible to specify a branch with the --branch
option. If you specify a vendor and name directly after the url, those will be used instead of the pieces of the url.
Command:
$ php artisan packager:tests
Result:
Packager will go through all maintaining packages (in packages/
) and publish their tests to tests/packages
.
Add the following to phpunit.xml (under the other testsuites) in order to run the tests from the packages:
<testsuite name="Packages">
<directory suffix="Test.php">./tests/packages</directory>
</testsuite>
Options:
$ php artisan packager:tests MyVendor MyPackage
Remarks: If a tests folder exists, the files will be copied to a dedicated folder in the Laravel App tests folder. This allows you to use all of Laravel's own testing functions without any hassle.
Command:
$ php artisan packager:list
Result:
An overview of all packages in the /packages
directory.
Command:
$ php artisan packager:remove MyVendor MyPackage
Result:
The MyVendor\MyPackage
package is deleted, including its references in composer.json
and config/app.php
.
Command:
$ php artisan packager:publish MyVendor MyPackage https://github.com/myvendor/mypackage
Result:
The MyVendor\MyPackage
package will be published to Github using the provided url.
Command:
$ php artisan packager:check MyVendor MyPackage
Result:
The MyVendor\MyPackage
package will be checked for security vulnerabilities using SensioLabs security checker.
Remarks You first need to run
$ composer require sensiolabs/security-checker
It turns out that, especially on Windows, there might arise some problems with the downloading of the skeleton, due to a file regarding SSL certificates missing on the OS. This can be solved by opening up your .env file and putting this in it:
CURL_VERIFY=false
Of course this means it will be less secure, but then again you are not supposed to run this package anywhere near a production environment.
DelveFore started to work on a cool project to use various Artisan make:
commands for the packages, check it out!
Please see changelog.md for what has changed recently.
Please see contributing.md for details and a todolist.
- MIT. Por favor leia o arquivo de licença para mais informações.
- The EU Public License. Please see license.md for more information.