murilo
238
2
General

It is that possible to gerate a new class with a custom artisan command ?

Posted 2 months ago by murilo

Hello Guys , I have a question . It is that possible to gerate a new class with a custom artisan command ?

I now how to create a custom command in artisan , but my question is how to gerate a PHP file . I wold like to make something like that -

    php artisan gerate:customClass

in console\Commands\gerateClass

 protected $signature = 'gerate:customClass';

protected $description = 'Gerate new Class';


 public function handle()
    {
        // create a php file
        $path = '\Classes\CustomClasses\MyClass';
        

        $class_template = '
            
            
                
             public function doThis()
                {
            ........
            }
                
        ';
}

Please sign in or create an account to participate in this conversation.