PHP code example of cyberbugz / dust

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

    

cyberbugz / dust example snippets


      #[Route(Http::POST, '/users', 'users.store')]
      public function store() {
          return response()->json(['message' => 'User created']);
      }
      

      #[Middleware(['auth', 'throttle:60,1'])]
      public function update() {
          return response()->json(['message' => 'Middleware applied']);
      }
      

      #[Guard('api')]
      public function index() {
          return response()->json(['message' => 'Secured by API guard']);
      }
      

      #[Prefix('admin')]
      #[Route(Http::GET, '/dashboard')]
      public function dashboard() {
          return response()->json(['message' => 'Admin dashboard']);
      }
      

      return new ErrorResponse('An error occurred.', ['error_code' => 123], 400);
      

      throw new RouteDefinitionMissing('Custom error message');
      

#[Middleware(['auth'])]
#[Guard('api')]
#[Prefix('admin')]
#[Route(Http::GET, '/users', 'users.index')]
public function index() {
    return response()->json(['message' => 'Admin API Users']);
}

          MyEnum::options();
          MyEnum::values();
          

      $array = $instance->toArray();
      

      $options = MyClass::options();
      

      $string = $instance->toString();
      

      $modulePath = get_module_path('User', ['Domain', 'Entities']);
      

      Logger::info('Operation completed successfully.', ['user_id' => 1]);
      Logger::error('An error occurred.', $exception, ['context' => 'value']);
      
bash
php artisan vendor:publish --provider="Dust\Providers\DustServiceProvider" --tag="dust-config"