Overview

Paxsy - Laravel Package Development

Features

packagist badge Test Coverage badge PestPHP badge Maintainability badge phpstan badge

✓ With Paxsy create|edit|refactor laravel packages and package components.

✓ You can use your Laravel packages directly without uploading the package to a package registry.

✓ administer packages via a console menu or|and laravel prompts and suggestions with options!

✓ creation is straightforward and fast, such as regular /app development in laravel!

✓ Paxsy is based as purely as possible on the Laravel package guidelines

✓ Packages they created with Paxsy are independent of Paxsy. In Clear words, Paxsy is only the Generator

✓ Supported 23 Laravel Make Commands

Updates against Bootraiser

Fresh installation

Filefabrik/Paxsy is installed in the same way as all other Laravel Composer packages:

installation via composer

composer require filefabrik/paxsy --dev

Start to create a Package

todo: php artisan package:discover

https://laravel.com/docs/11.x/packages

By default, all your packages created with Paxsy are created under ./app-paxsy. You can select a different directory. Please look under “change package directory

Paxsy offers two ways to create Packages and Package-Components.

  1. Via console “GUI” input.
  2. Via console input. read supported commands

Start from the Console GUI Menu

php artisan paxsy

select create package

2024-05-24_07-36

Fill in your vendor-name

MyCompany

2024-05-24_07-37

Insert the name of the package

TheCounter

2024-05-24_07-37_1

After the package has been created, you can directly create Laravel components such as casts/models etc. Additional components can be created in the respective package at a later phase.

alternative console commands

php artisan paxsy:package MyCompany TheCounter

more explanation: laravel package create composer package

make a route (optional)

To check immediately whether the created package works, create the default package route and open your Laravel page in the browser:

2024-05-24_07-38

your Laravel Site /the-counter/index 2024-05-24_07-47

reference: make:route

You have now created your first working package with Paxsy.

optional publish config

Paxsy does not require a customized configuration. All settings are already made so that you can start immediately.

If you know that you need your own settings for Paxsy, publish the paxsy-config with the console command:

php artisan vendor:publish

and select paxsy-config

or with direct command:

php artisan vendor:publish --tag=paxsy-config

If you do not need any extra settings for Paxsy at the moment, you can do this step at any time later.

Change package directory (optional)

Have you already developed your own vendor/packages under /packages or under /app-modules? No problem!

First publish the paxsy-config as described or direct

Under Laravel Directory /config/paxsy.php change the value of stack_name from app-paxsy to packages or something else. However, it must be in the Laravel root and must not be nested!

Background: Other/individual approaches: InterNACHI with /app-modules as well as Laravel’s recommendation /packages have technically no influence on the development of your own Laravel vendor/packages. /app-modules are quite good, as the usual Laravel app’s own files are located under /app. Visually, /app and /app-modules are located one below the other.

Packages are automatically working!

To be able to use a package in Laravel, two things are necessary.

  1. the correct entries in composer.json (laravel host composer)
  2. boot the parts of your package with Laravel

Both are done automatically by paxsy when creating a package.

composer.json (laravel host)

In Filefabrik/Paxsy, each vendor/package is integrated individually into the laravel composer.json with its own repository entry.

The reason for the individual repositories is that vendor/packages that you have included in an app-paxsy|app-module|packages can also be included via the packages-composer repository. Then your Laravel works with your vendor/package via /vendors/your-company/your-package.

changes composer.json

To get your packages handled by laravel, these packages have to be registered in laravel host composer.json.

Updates to composer.json are required for

  • create Package
  • disable Package
  • add local repository
  • remove local repository

Paxsy can handle the composer relevant tasks in two different ways.

  • Write only into composer.json and execute the changes while using your terminal
  • Execute directly with php shell_exec

I expect that you are using a local dev-environment when creating VendorPackages. The shell_exec function is usually available in local dev environments. For security reasons shell_exec should be disabled in php.ini on live-servers!

To have a better overview of the repositories created with paxsy in the laravel host composer.json, these repository entries are provided with the key-prefix “paxsy”.

{
  "repositories": {
    "paxsy-app-paxsy/the-counter": {
      "type": "path",
      "url": "app-paxsy/the-counter",
      "options": {
        "symlink": true
      }
    }
  }
}

todo is enough to dump-autoload if there are no dependencies needed for the package.

This should make it easier for you to remove repositories from this composer.json manually if necessary.

This also makes it easier for you to switch between the real package registry and your local repository.

bootraiser

To massively speed up your package development, the ServiceProvider (TheCounterServiceProvider) is automatically equipped with the bootloader bootraiser. You can remove the bootraiser at any time and modify it with your own boot functions. The bootraiser is not a fixed dependency, but rather a service.

Last updated on