PHP code example of kiendaotac / laravel-package-tools

1. Go to this page and download the library: Download kiendaotac/laravel-package-tools 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/ */

    

kiendaotac / laravel-package-tools example snippets


use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelPackageTools\Package;

class YourPackageServiceProvider extends PackageServiceProvider
{
    public function configurePackage(Package $package): void
    {
        $package
            ->name('your-package-name')
            ->hasConfigFile()
            ->hasViews()
            ->hasTranslations()
            ->hasAssets()
            ->hasRoute('web')
            ->hasMigration('create_package_tables')
            ->hasCommand(YourCoolPackageCommand::class);
    }
}

use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelPackageTools\Package;

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

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

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

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



return [
    'translatable' => 'translation',
];

trans('your-package-name::translations.translatable'); // returns 'translation'

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

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

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

$package
    ->name('your-package-name')
    ->hasCommand(YourCoolPackageCommand::class);

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

$package
    ->name('your-package-name')
    ->hasRoute('web');

$package
    ->name('your-package-name')
    ->hasRoutes(['web', 'admin']);