PHP code example of laravilt / plugins

1. Go to this page and download the library: Download laravilt/plugins 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/ */

    

laravilt / plugins example snippets


return [
    'defaults' => [
        'vendor' => env('LARAVILT_PLUGINS_DEFAULT_VENDOR', 'laravilt'),
        'author' => env('LARAVILT_PLUGINS_DEFAULT_AUTHOR', 'Your Name'),
        'email' => env('LARAVILT_PLUGINS_DEFAULT_EMAIL', '[email protected]'),
        'license' => env('LARAVILT_PLUGINS_DEFAULT_LICENSE', 'MIT'),
        'github_sponsor' => env('LARAVILT_PLUGINS_DEFAULT_GITHUB_SPONSOR', 'yourusername'),
    ],
];



namespace App\PluginFeatures;

use Laravilt\Plugins\Features\AbstractFeature;

class CustomFeature extends AbstractFeature
{
    public function getName(): string
    {
        return 'custom';
    }

    public function shouldGenerate(array $config): bool
    {
        return $config['generate_custom'] ?? false;
    }

    public function getPriority(): int
    {
        return 99; // Execute near the end
    }

    public function generate(array $config): void
    {
        // Your generation logic
        $this->processor->generateFile(
            $config['base_path'].'/custom/file.php',
            'custom/file',
            ['key' => 'value']
        );
    }
}

'features' => [
    // ... existing features
    \App\PluginFeatures\CustomFeature::class,
],
bash
php artisan vendor:publish --tag=laravilt-plugins-config
bash
php artisan laravilt:install-mcp
bash
php artisan laravilt:plugin MyPlugin
bash
php artisan laravilt:plugin MyPlugin --no-interaction
bash
php artisan laravilt:make