zencodex/package-make

This package is abandoned and no longer maintained. No replacement package was suggested.

create separate laravel package/plugin

v1.0.6 2022-02-26 07:55 UTC

This package is auto-updated.

Last update: 2022-07-01 00:08:37 UTC


README

package-make was abandon, please use packagit:

https://github.com/packagit/packagit

Create PHP or laravel package/plugin

Latest Version on Packagist Build Status Quality Score Total Downloads

You can manage huge project with many separate laravel packages.

Thanks to nwidart/laravel-modules, I get many code from it and reimplement.

Why I re-implement (don't use nwidart/laravel-modules)?

  1. nwidart/laravel-modules stubs injected module_path, you can't remove it in production.
  2. Just a standard composer package, you don't need nwidart/laravel-modules to manage modules.
  3. Update some stubs and folders structure, keep it like laravel.
  4. You can remove this package in production, Just required in devepopment.

So I seperate new one zencodex/package-make, resovled above issues.

Installation

You can install the package via composer:

composer require --dev zencodex/package-make

Usage

// modules/NewPackage
php artisan package:make NewPackage

NewPackage structure:

modules/NewPackage
├── Config
│   └── config.php
├── Console
│   └── UserCommand.php
├── Database
│   ├── Migrations
│   ├── Seeders
│   │   └── NewPackageDatabaseSeeder.php
│   └── factories
├── Http
│   ├── Controllers
│   │   └── NewPackageController.php
│   ├── Middleware
│   ├── Requests
│   └── Resources
│       └── UserResource.php
├── Models
│   └── User.php
├── Providers
│   ├── NewPackageServiceProvider.php
│   └── RouteServiceProvider.php
├── Resources
│   ├── assets
│   │   ├── js
│   │   │   └── app.js
│   │   └── sass
│   │       └── app.scss
│   ├── lang
│   └── views
│       ├── index.blade.php
│       └── layouts
│           └── master.blade.php
├── Routes
│   ├── api.php
│   └── web.php
├── Tests
│   ├── Feature
│   └── Unit
├── composer.json
├── package.json
└── webpack.mix.js

Custom namespace and path

php artisan vendor:publish --tag=package

// edit config/package.php
// use namespace Balabala
// generate package files in plugins folder

return [

     // Custom package namespace
    'namespace' => 'Balabala',

    'paths'     => [
        // Custom generated files path
        'modules' => base_path('plugins'),

// ...

Usage in project

option 1:

// app/Providers/AppServiceProvider.php

use Package\NewPackage\Providers\NewPackageServiceProvider;

class AppServiceProvider extends ServiceProvider

    public function register()
    {
        $this->app->register(NewPackageServiceProvider::class);
        ...
    }

or

Edit config/app.php, add Package\NewPackage\Providers\NewPackageServiceProvider::class to providers.

    'providers' => [
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Package\NewPackage\Providers\NewPackageServiceProvider::class
        ...
    ],

option 2:

// 1. edit composer.json, add following
"repositories": [
    {
        "type": "path",
        "url": "modules/*"
    }
]

// use private package or gitlab
"repositories": [
    {
        "type": "vcs",
        "url": "git@gitlab.example.com:/newpackage.git"
    }
]

// 2. composer require local path package (replace package/newpackage to yours)
composer require package/newpackage

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email v@yinqisen.cn instead of using the issue tracker.

Credits

License

The Apache License 2. Please see License File for more information.