PHP code example of kaue-f / laravel-structura
1. Go to this page and download the library: Download kaue-f/laravel-structura 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/ */
kaue-f / laravel-structura example snippets
> Status::toData(); // Minimalist: ['id' => '...', 'name' => '...']
> Status::toData(color: true, icon: true); // Includes color and icon attributes
> Status::toData(map: ['value' => 'id', 'label' => 'name']); // Custom key renaming
> Status::toData(map: ['extra' => fn($case) => $case->extra()]); // Closure resolution
>
> return ServiceResult::success($data);
> return ServiceResult::failure('Error message');
>
'default_options' => [
'action' => [
'execute' => true, // Default method
'makeable' => true, // All new actions get Makeable trait by default
'transaction' => false,
],
'service' => [
'makeable' => false,
'result' => false,
],
'data' => [
'no-final' => false,
'no-readonly' => false,
],
'enum' => [
'backed' => 'string', // Default backing type: 'string' | 'int' | null
],
// ...
],
bash
php artisan structura:install
php artisan structura:install --force # Force overwrite
bash
php artisan boost:install
bash
php artisan structura:trait Loggable
app/
├── Actions/
│ └── LogoutAction.php
│
├── Caches/
│ └── ClassificationCache.php
│
├── Concerns/
│ └── Loggable.php
│
├── Data/
│ └── UserData.php
│
├── Enums/
│ └── StatusEnum.php
│
├── Helpers/
│ ├── helpers.php
│ ├── StringHelper.php
│ └── string_helper.php
│
├── Services/
│ └── CommentService.php