PHP code example of ronasit / larabuilder

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

    

ronasit / larabuilder example snippets


new PHPFileBuilder(app_path('Models/User.php'))
    ->addArrayPropertyItem('fillable', 'is_active')
    ->setProperty('casts', [
        'is_active' => 'boolean',
    ], AccessModifierEnum::Protected)
    ->save();

new PHPFileBuilder(app_path('Http/Controllers/UserController.php'))
    ->addMethod(
        name: 'delete',
        code: '
            $service->delete($id);
            return response()->noContent();
        ',
        params: new MethodParamsList(
            new MethodParamDTO(name: 'request', type: 'DeleteRequest'),
            new MethodParamDTO(name: 'service', type: 'UserService'),
            new MethodParamDTO(name: 'id', type: 'int'),
        ),
        returnType: 'Response',
    )
    ->save();

new AppBootstrapBuilder()->addExceptionsRender(ExpectationFailedException::class,  '
    throw $exception;
')->save();