A cli tool for creating Laravel packages

Overview

Laravel Packager

Latest Version on Packagist Total Downloads Build Status StyleCI

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. If you like a visual explanation check out this video by Jeffrey Way on Laracasts.

Installation

Via Composer

$ composer require jeroen-g/laravel-packager --dev

If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php:

JeroenG\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('JeroenG\Packager\PackagerServiceProvider');
}

Optional you can publish the configuration to provide a different service provider stub. The default is here.

$ php artisan vendor:publish --provider="JeroenG\Packager\PackagerServiceProvider"

Available commands

New

Command:

$ php artisan packager:new MyVendor MyPackage

Result: The command will handle practically everything for you. It will create a packages directory, creates the vendor and package directory in it, pulls in a skeleton package, sets up composer.json and creates a service provider.

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.

$ php artisan packager:new MyVendor/MyPackage

Alternatively you may also define your vendor and name with a forward slash instead of a space.

Remarks: The new package will be based on this custom skeleton. If you want to use a different package skeleton, you can either:

  • (A) publish the configuration file and change the default skeleton that will be used by all packager:new calls.
  • (B) use the flag --skeleton="http://github.com/path/to/archive/master.zip" with your own skeleton to use the given skeleton for this one run instead of the one in the configuration.

Get & Git

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.

Tests

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.

List

Command:

$ php artisan packager:list

Result: An overview of all packages in the /packages directory.

Options:

$ php artisan packager:list --git

The packages are displayed with information on the git status (branch, commit difference with origin) if it is a git repository.

Remove

Command:

$ php artisan packager:remove MyVendor MyPackage

Result: The MyVendor\MyPackage package is deleted, including its references in composer.json and config/app.php.

Publish

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.

Check

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

Issues with cURL SSL certificate

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.

Issues with timeout

If you are having problems with timeouts when creating new packages, you can now change the config variable timeout in config/packager.php to fix this.

Changelog

Please see changelog.md for what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Credits

License

The EU Public License. Please see license.md for more information.

Comments
  • Feasible to include App namespace in package?

    Feasible to include App namespace in package?

    Hi,

    I'm looking to use the make:controller etc commands for packages, however they use the App namespace by default and there doesn't seem to be an elegant way to intercept the command to change it.

    I actually added a App namespace into composer.json of each package (at the risk of class names conflicts) and then move the controller/model/etc file into the package's app folder.

      "autoload": {
        "psr-4": {
          "App\\": "app/",
          ...
        }
      },
    

    Is there a better way? How are you guys doing it?

    opened by bilogic 9
  • Add ability to set timeout

    Add ability to set timeout

    Hi

    Kept having timeout when trying to create new projects. (Assuming as in South Africa).

    I've added the ability to set the Symphony process timeout for packager:new

    opened by timhaak 9
  • Wrong Provider and Alias in the composer.json file

    Wrong Provider and Alias in the composer.json file

    Assuming we have a package called: barryvdh/debugbar The service provider and alias are written by this package this way:

    "extra": {
        "laravel": {
            "providers": [
                "DebugbarServiceProvider"
            ],
            "aliases": {
                "Debugbar": "Debugbar"
            }
        }
    },
    

    I get the Laravel PackageRepository.php line 208 error saying, I couldn't find the DebugbarServiceProvider file.

    Wrtitng the composer.json file in the package directory this way will solve the issue:

    "extra": {
        "laravel": {
            "providers": [
                "Barryvdh\\Debugbar\\DebugbarServiceProvider"
            ],
            "aliases": {
                "Debugbar": "Barryvdh\\Debugbar\\Debugbar"
            }
        }
    },
    

    So the problem is laravel-packager doesn't include the full path of both the service provider and alias.

    opened by armancodes 9
  • Classes vendor-name package-name not converted to studly (pascal) case

    Classes vendor-name package-name not converted to studly (pascal) case

    If I create my package with name like:

    php artisan packager:new my-vendor my-package

    Then I expect that my class names are:

    MyVendor MyPackage

    but instaed they are:

    namespace my-vendor\my-package;
    
    class my-package
    {
        // Build wonderful things
    }
    
    // service provider
    namespace my-vendor\my-package;
    
    use Illuminate\Support\ServiceProvider;
    
    class my-packageServiceProvider extends ServiceProvider
    {
    //...
    }
    

    Should not be converted to camel case "my-vendor" and "my-package"?

    The package itself would fail if we try to create like this:

    php artisan packager:new jeroen-g laravel-packager

    This could be easy fixed by converting to camel case only the class name and file names, apart vendor and package folder.

    What do you think?

    opened by thewebartisan7 8
  • Use Composer path repositories to install packages in parent project.

    Use Composer path repositories to install packages in parent project.

    Hi, thanks for an excellent package.

    I've made a few changes that I think makes the workflow a bit simpler and more intuitive. By using path repositories in the parent project, the packages can be installed exactly like any other package. Here are the benefits as I see them:

    • No need to install/update dependencies in the package sub-folders. Everything is managed from the project root.
    • Service providers are discovered automatically during installation.
    • Classes in the package namespaces are autoloaded automatically just like any other package.
    • Having only one vendor/ folder means no duplicate dependencies, which tend to confuse IDEs like PhpStorm.

    Let me know if anything needs to be changed.

    opened by mortenscheel 8
  • Vendor Namespace and Package Name should be StudlyCased in the namespace

    Vendor Namespace and Package Name should be StudlyCased in the namespace

    The vendor namespace and package name should be lowercased in the directory tree, but they should be StudlyCased in the class definition.

    When I run:

    $ artisan packager:new tokenly fluentd-logger
    

    The Expected result is:

    Should create a namespace of namespace definition of Tokenly\FluentdLogger;

    The actual Result is:

    Creates namespace tokenly\fluentd-logger;

    Here is an example of capitilization in a Laravel vendor package:

    skeletonclass_php_ _tokenly-dashboard command_php_ _tokenly-dashboard

    opened by deweller 8
  • use correct placeholders of league skeleton

    use correct placeholders of league skeleton

    composer.json contained a bunch of unreplaced placeholders. Not sure how that package could have worked for you guys in the last few months, but from what I can see the placeholders were changed on Nov 27, 2015

    https://github.com/thephpleague/skeleton/commit/d048eb97f87bb2546f1444528a75d109b70ae2e8

    opened by Remo 8
  • Should list cURL as a requirement

    Should list cURL as a requirement

    I get the following error message when I try to use your package.

    [GuzzleHttp\Exception\RequestException]
      cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.ht
      ml)
    

    I can not use cURL in my environment (behind a proxy) so I guess it's a non-starter. So just thought I should let you know that it is a requirement of being able to use your package.

    Thanks.

    opened by landjea 8
  • packager:new should accept vendor/name

    packager:new should accept vendor/name

    Hi,

    I have been using laravel-packager for a while now, really great work! :) Is it possible make the command packager:new to accept a vendor and name in the format of vendor/name?

    Thank you.

    opened by bilogic 5
  • Bug: dash in package name and first symbol is numeric

    Bug: dash in package name and first symbol is numeric

    php artisan packager:new 4n70w4 Laravel-OKVED

     0/6 [>---------------------------]   0% Creating package 4n70w4\Laravel-OKVED...
     1/6 [====>-----------------------]  16% Creating packages directory...
     2/6 [=========>------------------]  33% Creating vendor...
     3/6 [==============>-------------]  50% Downloading skeleton...
     4/6 [==================>---------]  66% Replacing skeleton placeholders...
     5/6 [=======================>----]  83% Dumping autoloads and discovering package...
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
    Generating optimized autoload files> Illuminate\Foundation\ComposerScripts::postAutoloadDump
    > @php artisan package:discover --ansi
    Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
     6/6 [============================] 100% Package created successfully!
    

    Generated packages/4n70w4/Laravel-OKVED/src/Laravel-OKVED.php:

    <?php
    
    namespace 4n70w4\Laravel-OKVED;
    
    class Laravel-OKVED
    {
        // Build wonderful things
    }
    
    1. Incorrect namespace: number as first symbol
    2. Incorrect classname: dash in classname

    The class name can be any valid label, provided it is not a PHP reserved word. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$.

    https://php.net/manual/en/language.oop5.basic.php

    opened by 4n70w4 5
  • Usage Question: How to install dependencies

    Usage Question: How to install dependencies

    I've built a package within a test project by php artisan packager:new MyVendor MyPackage. Now the MyPackage has a dependency on spatie/laravel-permission. How do I get the parent package to be aware of this dependency and publish the configuration file?

    opened by johntimothybailey 5
  • artisan packager:get fail

    artisan packager:get fail

    I have create a new 'package' using the Spatie skeleton

    then I use

    php artisan packager:get https://github.com/rabol/spoonacular-laravel
    
    

    but the command fails with this error:

    
     0/4 [>---------------------------]   0% Creating package rabol\spoonacular-laravel...
    Creating packages directory...
    Creating vendor...
    Downloading from Github...
    
       ErrorException 
    
      rename(/Users/rabol/code/web/recipe/packages/rabol/spoonacular-laravel-master,/Users/rabol/code/web/recipe/packages/rabol/spoonacular-laravel): No such file or directory
    
      at vendor/jeroen-g/laravel-packager/src/Conveyor.php:135
        131▕         $this->download($zipFile = $this->makeFilename(), $origin)
        132▕             ->extract($zipFile, $this->vendorPath())
        133▕             ->cleanUp($zipFile);
        134▕ 
      ➜ 135▕         rename($this->vendorPath().'/'.$piece.'-'.$branch, $this->packagePath());
        136▕     }
        137▕ 
        138▕     /**
        139▕      * Dump Composer's autoloads.
    
          +15 vendor frames 
      16  artisan:37
          Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    
    

    Laravel version 9.34.0 Php v 8.1.11

    opened by rabol 0
  • Problem when run packages with laravel 9.0

    Problem when run packages with laravel 9.0

    • Root composer.json requires yaap/theme ^4.1 -> satisfiable by yaap/theme[4.1.0].
      • yaap/theme 4.1.0 requires laravel/framework ^8.0 -> found laravel/framework[v8.0.0, ..., 8.x-dev] but it conflicts with your root composer.json require (^9.19).
    opened by ms08-067 1
  • All Packages Getting Deleted!

    All Packages Getting Deleted!

    I am using Laravel Sail and my PHP version is 8. So the version of Laravel Packager I got is 2.5. For some reason, when I delete a package, the rest of the packages are also getting deleted. I was just lucky that the package that got accidentally deleted is backed up.

    opened by luchmewep 1
  • cURL error 60: SSL certificate problem: unable to get local issuer certificate

    cURL error 60: SSL certificate problem: unable to get local issuer certificate

    when I add this command,

    php artisan packager:new Acme PageReview --i

    Getting this issue,

    GuzzleHttp\Exception\RequestException
    
      cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://github.com/Jeroen-G/packager-skeleton/archive/master.zip
    
      at C:\wamp64\www\taskman\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:211
        207▕
        208▕         // Create a connection exception if it was a specific error code.
        209▕         $error = isset($connectionErrors[$easy->errno])
        210▕             ? new ConnectException($message, $easy->request, null, $ctx)   ➜ 211▕             : new RequestException($message, $easy->request, $easy->response, null, $ctx);
        212▕
        213▕         return P\Create::rejectionFor($error);
        214▕     }
        215▕
    
      1   C:\wamp64\www\taskman\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:158
          GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle))
    
      2   C:\wamp64\www\taskman\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:110
          GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
    
    opened by vimuths123 1
  • Keywords not replaced

    Keywords not replaced

    Laravel 8.24 PHP 7.4.10 Homestead 9 (vagrant up via an admin cmd in windows 10)

    After the package version 2.6 is installed and when I try to create a new package using new command as following php artisan packager:new vend pack

    package is created in packages directory but the following keywords are not replaced.

    ':uc:vendor',
    ':uc:package',
    ':lc:vendor',
    ':lc:package',
    

    Following screenshot show how generated Facade class looks like.
    image

    Even the file names are not changed. Facade file is coming as packages/vend/pack/src/Facades/MyPackage.php

    opened by karmendra 2
Releases(2.8.0)
Owner
JeroenG
JeroenG
[Package] Lumen Testing Helper for Packages Development

anik/testbench-lumen is a package, highly inspired by the orchestral/testbench. orchestral/testbench that is a tool for testing Laravel packages.

Syed Sirajul Islam Anik 7 Jun 21, 2022
InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Read

InfyOmLabs (InfyOm Technologies) 3.5k Jan 1, 2023
:rocket: A Smart CRUD Generator For Laravel

Features Generate your models, views, controllers, routes and migrations just in a few clicks. Models visualization through a graph presentation (New

Houssain Amrani 891 Dec 23, 2022
Laravel IDE Helper

Laravel IDE Helper Generator Complete PHPDocs, directly from the source This package generates helper files that enable your IDE to provide accurate a

Barry vd. Heuvel 12.8k Dec 29, 2022
This package extends the core file generators that are included with Laravel 5

Extended Migration Generators for Laravel 6, 7 and 8 Easily define the migration schema right in your make:migration command. The new commands this pa

Laracasts 2.4k Dec 29, 2022
⛔️ Laravel Tinx is archived and no longer maintained.

⛔️ Laravel Tinx (Deprecated) Laravel Tinx was archived on 12th December 2019 and is no longer maintained. Looking for a reloadable version of Laravel

James Furey 440 Dec 27, 2022
Laravel API Documentation Generator

Laravel API Documentation Generator Automatically generate your API documentation from your existing Laravel/Lumen/Dingo routes. php artisan apidoc:ge

Marcel Pociot 3.3k Dec 21, 2022
A MySQL Workbench plugin which exports a Model to Laravel 5 Migrations

MySQL Workbench Export Laravel 5 Migrations Plugin A MySQL Workbench plugin that allows for exporting a model to Laravel 5 migrations that follow PSR-

Brandon Eckenrode 902 Jan 2, 2023
🍪 Write gorgeous documentation for your products using Markdown inside your Laravel app.

LaRecipe Write gorgeous documentations for your products using Markdown inside your Laravel app. LaRecipe ?? LaRecipe is simply a code-driven package

Saleem Hadad 2.1k Dec 29, 2022
Prequel for Laravel. Clear and concise database management.

TL;DR? Test Prequel here! What is Prequel exactly? Prequel is meant to be a database management tool for Laravel to replace the need for separate stan

Protoqol 1.4k Dec 27, 2022
Module Generator Composer Package For Laravel

Module Generator Installation You can install the package via composer: composer require teacoders/module-generator Run the command below to publish t

Tea Coders 21 Jan 8, 2022
Creates an 'artisan workflow:make' command to scaffold out a number of useful GitHub actions workflows for Laravel

Laravel workflow generator This creates a make:workflow artisan command to scaffold out a number of useful GitHub actions workflows for Laravel. Insta

Len Woodward 9 Jul 18, 2021
Tools for creating Laravel packages

Tools for creating Laravel packages This package contains a PackageServiceProvider that you can use in your packages to easily register config files,

Spatie 526 Dec 29, 2022
This composer plugin allows you to share your selected packages between your projects by creating symlinks

Composer - Shared Package Plugin This composer plugin allows you to share your selected packages between your projects by creating symlinks. All share

L'Etudiant 169 Sep 20, 2022
Cilex a lightweight framework for creating PHP CLI scripts inspired by Silex

Cilex, a simple Command Line Interface framework Cilex is a simple command line application framework to develop simple tools based on Symfony2 compon

null 624 Dec 6, 2022
Library for creating CLI commands or applications

Console Motivation: this library purpose is to provide a lighter and more robust API for console commands and/or applications to symfony/console. It c

Théo FIDRY 16 Dec 28, 2022
Basis for creating a CLI with php

Firulin-core v1 From Firulin-core you can create a CLI any way you want, adding new commands easily. Requeriments PHP 7.4^ Composer Get started co

Márrios 5 Jul 19, 2022
💫 Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan / Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、WorkerMan

Mix Vega 中文 | English Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、Work

Mix PHP 46 Apr 28, 2022
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server

☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server

Mix PHP 1.8k Jan 3, 2023
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Serve

☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server

Mix PHP 1.8k Dec 29, 2022