Laravel Packager

repository·master·Indexed 23 days ago

https://github.com/jeroen-g/laravel-packager

A developer tool for Laravel designed to simplify the creation, management, and testing of Laravel packages. It automates boilerplate setup via the `packager:new` command, allows importing existing repositories with `packager:get` and `packager:git`, and provides utilities for listing, removing, enabling, disabling, and publishing packages to GitHub. It also includes a `packager:tests` command to integrate package tests into the main Laravel testing infrastructure and a `packager:check` command for security vulnerability scanning using SensioLabs Security Checker.

Tokens
4.2K
Snippets
13
Records
33
Agent score
78%

What's inside laravel-packager

  1. Setup package testing with `packager:tests`

    master

    The packager:tests command iterates through all maintained packages in the packages/ directory and publishes their tests to tests/packages within your Laravel app. This allows you to run package tests using Laravel's testing infrastructure.

    Command:

    php artisan packager:tests

    Targeted Testing:

    php artisan packager:tests my-vendor my-package

    Configuration: To run these tests via PHPUnit, add the following suite to your phpunit.xml:

    <testsuite name="Packages">
        <directory suffix="Test.php">./tests/packages</directory>
    </testsuite>
  2. Configure Service Provider for Laravel < 5.5

    master

    If you are using a version of Laravel older than 5.5, you must manually register the service provider in config/app.php:

    JeroenG\Packager\PackagerServiceProvider::class,

    For Laravel 5.5+, the package is automatically discovered. If you want to prevent the package from loading in production environments, you can disable auto-discovery and register it conditionally in your AppServiceProvider:

    if ($this->app->environment('local')) {
        $this->app->register('JeroenG\Packager\PackagerServiceProvider');
    }
  3. Troubleshoot cURL SSL and Timeout issues

    master

    cURL SSL Certificate issues

    On Windows, downloading skeletons may fail due to missing SSL certificates. You can bypass verification by adding this to your .env file (Note: this is less secure and intended for local development only):

    CURL_VERIFY=false

    Timeout issues

    If packager:new commands time out, you can increase the timeout limit in config/packager.php.

  4. Configure package scaffolding via packager config

    master

    The packager:new command uses several configuration values from the packager config file to populate package placeholders. If not using interactive mode (--i), the following keys are used:

    • packager.skeleton: The default package skeleton to download.
    • packager.author_name: The name of the package author.
    • packager.author_email: The email address of the package author.
    • packager.author_homepage: The website URL of the package author.
    • packager.license: The license type for the package.
  5. List and Remove packages

    master

    List packages

    View an overview of all packages in the /packages directory.

    php artisan packager:list
    • Git Status: Use --git to see branch and commit information for Git repositories.

    Remove a package

    Delete a package and its references in composer.json and config/app.php.

    php artisan packager:remove my-vendor my-package
  6. Create a new package with `packager:new`

    master

    Use the packager:new command to scaffold a new package. This creates a packages directory, sets up the vendor/package structure, pulls in a skeleton, configures composer.json, and creates a service provider.

    Basic Usage:

    php artisan packager:new my-vendor my-package

    Alternative Syntax:

    php artisan packager:new my-vendor/my-package

    Options:

    • --i: Run the command interactively to configure composer.json settings like license and description.
    • --skeleton="URL": Use a specific skeleton URL instead of the default configured in config/packager.php.

    Note: The default skeleton is https://github.com/jeroen-g/packager-skeleton.

  7. Import packages with `packager:get` and `packager:git`

    master

    Register existing repositories into your application's composer.json.

    packager:get (Download only)

    Downloads the package without the Git history.

    php artisan packager:get https://github.com/author/repository
    • Bitbucket Support: Use the --host=bitbucket flag.
    • Branch: Use --branch=name to specify a branch.
    • Custom Naming: Provide vendor and package names after the URL to override the URL components: php artisan packager:get <url> my-vendor my-package.

    packager:git (Clone repository)

    Clones the entire Git repository.

    php artisan packager:git https://github.com/author/repository
    • Custom Naming: php artisan packager:git <url> my-vendor my-package.
  8. Publish and Check packages

    master

    Publish to GitHub

    Publish a package to GitHub using a provided URL.

    php artisan packager:publish my-vendor my-package https://github.com/my-vendor/my-package

    Security Check

    Check a package for security vulnerabilities using the SensioLabs security checker. Requirement: You must first run composer require sensiolabs/security-checker.

    php artisan packager:check my-vendor my-package
  9. Uninstall a package from a Laravel project

    master

    The uninstallPackage() method reverses the installation process. It removes the package as a Composer dependency and unsets the path repository configuration in composer.json.

    It performs:

    1. removePackage(): Runs composer remove vendor/package.
    2. removePathRepository(): Unsets the repository entry in composer.json using the slugified vendor and package names.