PHPackages                             porifa/laravel-package-kit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. porifa/laravel-package-kit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

porifa/laravel-package-kit
==========================

Toolkit for creating Laravel packages

v1.3.0(2y ago)2637[3 PRs](https://github.com/porifa/laravel-package-kit/pulls)3MITPHPPHP ^8.1CI passing

Since Aug 12Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/porifa/laravel-package-kit)[ Packagist](https://packagist.org/packages/porifa/laravel-package-kit)[ Docs](https://github.com/porifa/laravel-package-kit)[ RSS](/packages/porifa-laravel-package-kit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (10)Versions (9)Used By (3)

Toolkit for creating Laravel packages
=====================================

[](#toolkit-for-creating-laravel-packages)

[![Latest Version](https://camo.githubusercontent.com/cadeb1bb80bd0f726cd79968abe9311904e27a736e5dfcff5ed786a1bb23c463/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f726966612f6c61726176656c2d7061636b6167652d6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/porifa/laravel-package-kit)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0227c9b154ee5b3ccd2788f1ad3c84f8fbf23f3d2a702e2b0099321bf96d1986/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f706f726966612f6c61726176656c2d7061636b6167652d6b69742f706573743f6c6162656c3d5465737473253230285065737429)](https://github.com/porifa/laravel-package-kit/actions?query=workflow%3Apest+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/f06ad2c62633439a9f455c8d149690efa4afe30df75231d2427cbb3044013958/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f706f726966612f6c61726176656c2d7061636b6167652d6b69742f50696e743f6c6162656c3d436f64652532305374796c652532302850696e7429)](https://github.com/porifa/laravel-package-kit/actions?query=workflow%3Apint+branch%3Amain)[![Quality Score](https://camo.githubusercontent.com/b387d946a229b68a155a22e9d498650e7258eed261e327bbdfc872c05426be45/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706f726966612f6c61726176656c2d7061636b6167652d6b69742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/porifa/laravel-package-kit)[![Downloads](https://camo.githubusercontent.com/137c658f42f70e782bc79bab42cfc9a1585f670e3201f5ea9b79275073960d88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706f726966612f6c61726176656c2d7061636b6167652d6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/porifa/laravel-package-kit)[![License](https://camo.githubusercontent.com/c1b7e66546ca1a169673fd8e3127298189b38078eadaae85a085923b19cec764/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706f726966612f6c61726176656c2d7061636b6167652d6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/porifa/laravel-package-kit)

This package contains a `PackageServiceProvider` that you can use in your packages to easily register config files, commands, migrations and more.

Usage
-----

[](#usage)

In your package you should let your service provider extend `Porifa\LaravelPackageKit\PackageServiceProvider`.

```
use Porifa\LaravelPackageKit\PackageServiceProvider;
use Porifa\LaravelPackageKit\Package;

class YourPackageServiceProvider extends PackageServiceProvider
{
    public function configurePackage(Package $package): void
    {
        $package
            ->name('your-package-name')
            ->hasConfigFiles()
            ->hasViews();
    }
}
```

Passing the package name to `name` is mandatory.

### Working with a config file

[](#working-with-a-config-file)

To register a config file, you should create a php file with your package name in the `config` directory of your package. In this example it should be at `/config/your-package-name.php`.

To register that config file, call `hasConfigFiles()` on `$package` in the `configurePackage` method.

```
$package
    ->name('your-package-name')
    ->hasConfigFiles();
```

If no parameter is passed in `hasConfigFiles` method then we use a convension, if your package name starts with `laravel-`, we expect that your config file does not contain that prefix. So if your package name is `laravel-cool-package`, the config file should be named `cool-package.php`.

The `hasConfigFiles` method will also make the config file publishable. Users of your package will be able to publish the config file with this command.

```
php artisan vendor:publish --tag=your-package-name-config
```

If your package have multiple config files then you can pass their names as an array to `hasConfigFiles`

```
$package
    ->name('your-package-name')
    ->hasConfigFiles(['config-file1', 'config-file2']);
```

### Working with commands

[](#working-with-commands)

You can register any command you package provides with the `hasCommands` method.

```
$package
    ->name('your-package-name')
    ->hasCommands(YourPackageCommand::class);
```

If your package provides multiple commands, you can pass an array to `hasCommands` method.

```
$package
    ->name('your-package-name')
    ->hasCommands([
        YourPackageCommand::class,
        YourOtherPackageCommand::class,
    ]);
```

### Working with migrations

[](#working-with-migrations)

To register your migration(s), you should create `php` OR `php.stub` file(s) in the `database/migrations` directory of your package. In this example it should be at `/database/migrations`.

To register migrations, call `hasMigrations()` on `$package` in the `configurePackage` method and you should pass its name without the extension to the `hasMigrations` method.

If your migration file is called `create_my_package_tables.php.stub` you can register them like this:

```
$package
    ->name('your-package-name')
    ->hasMigrations('create_my_package_tables');
```

If your package provides multiple migration files, you can pass an array to `hasMigrations` method.

```
$package
    ->name('your-package-name')
    ->hasMigrations(['my_package_tables', 'some_other_migration']);
```

Calling `hasMigrations` will also make migrations publishable. Users of your package will be able to publish the migrations with this command:

```
php artisan vendor:publish --tag=your-package-name-migrations
```

Like you might expect, published migration files will be prefixed with the current datetime.

You can also enable the migrations to be registered without needing the users of your package to publish them:

```
$package
    ->name('your-package-name')
    ->hasMigrations(['my_package_tables', 'some_other_migration'])
    ->runsMigrations();
```

### Working with views

[](#working-with-views)

To register your views, you should create `.blade.php` file(s) in the `resources/views` directory of your package. In this example it should be at `/resources/views`.

To register views, call `hasViews()` on `$package` in the `configurePackage` method.

```
$package
    ->name('your-package-name')
    ->hasViews();
```

Calling `hasViews` will also make views publishable. Users of your package will be able to publish the views with this command:

```
php artisan vendor:publish --tag=your-package-name-views
```

If you have a view `/resources/views/myView.blade.php`, you can use it like this: `view('your-package-name::myView')`. Of course, you can also use subdirectories to organise your views. A view located at `/resources/views/subdirectory/myOtherView.blade.php` can be used with `view('your-package-name::subdirectory.myOtherView')`.

If you want to use custom namespace then pass it to the `hasViews` method. If your custom namespace is `cool-namespace` you can use like this:

```
$package
    ->name('your-package-name')
    ->hasViews('cool-namespace');
```

Now you can use it like this

```
view('cool-namespace::myView');
```

Like you might expect, views are also registered without needing the users of your package to publish them.

### Sharing global data with views

[](#sharing-global-data-with-views)

You can share data with all views using the `sharesDataWithAllViews` method. This will make the shared variable available to all views.

```
$package
    ->name('your-package-name')
    ->sharesDataWithAllViews('companyName', 'Porifa');
```

### Working with Blade view components

[](#working-with-blade-view-components)

Any Blade view components that your package provides should be placed in the `/src/Components` directory.

You can register these views with the `hasViewComponents` command.

```
$package
    ->name('your-package-name')
    ->hasViewComponents('foobar', Cool::class);
```

This will register your view components with Laravel. In the case of `Cool::class`, it can be referenced in views as ``, where `foobar` is the prefix you provided during registration.

Calling `hasViewComponents` will also make view components publishable, and will be published to `app/Views/Components/vendor/`.

Users of your package will be able to publish the view components with this command:

```
php artisan vendor:publish --tag=your-package-name-components
```

### Working with view composers

[](#working-with-view-composers)

You can register any view composers that your project uses with the `hasViewComposers` method. You may also register a callback that receives a `$view` argument instead of a classname.

To register a view composer with all views, use an asterisk as the view name `'*'`.

```
$package
    ->name('your-package-name')
    ->hasViewComposer('viewName', MyViewComposer::class)
    ->hasViewComposer('*', function($view) {
        $view->with('sharedVariable', 123);
    });
```

### Using lifecycle hooks

[](#using-lifecycle-hooks)

According to your package needs, You can put any custom logic in these methods:

- `packageRegistering`: will be called at the start of the `register` method of `PackageServiceProvider`
- `packageRegistered`: will be called at the end of the `register` method of `PackageServiceProvider`
- `packageBooting`: will be called at the start of the `boot` method of `PackageServiceProvider`
- `packageBooted`: will be called at the end of the `boot` method of `PackageServiceProvider`

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/porifa/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Aamir Sohail KmAs](https://github.com/AamirSohailKmAs)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance60

Regular maintenance activity

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 59.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~91 days

Total

5

Last Release

1007d ago

Major Versions

v0.0.1-alpha → v1.0.02022-08-31

PHP version history (2 changes)v0.0.1-alphaPHP ^8.1

v1.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/135db8e9b4c1175442f1c6866e95769d245c5bf3396e486a7062179067c33e54?d=identicon)[AamirSohailKmAs](/maintainers/AamirSohailKmAs)

---

Top Contributors

[![AamirSohailKmAs](https://avatars.githubusercontent.com/u/53037997?v=4)](https://github.com/AamirSohailKmAs "AamirSohailKmAs (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (28 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")

---

Tags

laravellaravel-package-kitpackagephpporifaporifapackage-kitpackage-toolkitlaravel-package-kitlaravel-package-toolkit

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/porifa-laravel-package-kit/health.svg)

```
[![Health](https://phpackages.com/badges/porifa-laravel-package-kit/health.svg)](https://phpackages.com/packages/porifa-laravel-package-kit)
```

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[tonysm/rich-text-laravel

Integrates Trix content with Laravel

46577.8k1](/packages/tonysm-rich-text-laravel)[mauricius/laravel-htmx

Laravel helper library for Htmx

364101.1k1](/packages/mauricius-laravel-htmx)[illuminate/reflection

The Illuminate Reflection package.

361.6M3](/packages/illuminate-reflection)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[spatie/laravel-screenshot

Take screenshots of web pages in Laravel apps

7615.9k2](/packages/spatie-laravel-screenshot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
