PHP code example of porifa / laravel-package-kit

1. Go to this page and download the library: Download porifa/laravel-package-kit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

porifa / laravel-package-kit example snippets


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();
    }
}

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

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

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

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

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

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

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

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

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

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

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

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

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