PHP code example of cachewraith / laravel-template-structure

1. Go to this page and download the library: Download cachewraith/laravel-template-structure 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/ */

    

cachewraith / laravel-template-structure example snippets


$this->app->bind(ItemRepositoryInterface::class, InMemoryItemRepository::class);

'api_version_prefix' => env('CACHEWRAITH_API_PREFIX', 'api'),
'versions' => ['v1'],

'versions' => ['v1', 'v2'],

   use Laravel\Sanctum\HasApiTokens;

   class User extends Authenticatable
   {
       use HasApiTokens, HasFactory, Notifiable;
   }
   
bash
composer cachewraith:install          # asks which front door; defaults to api
composer dump-autoload
php artisan install:api                  # Laravel 11+ — installs Sanctum (API stack only)
php artisan migrate
bash
php artisan cachewraith:install --stack=api    # versioned JSON API (the default)
php artisan cachewraith:install --stack=web    # Blade UI, session auth, no build step
php artisan cachewraith:install --stack=both   # one set of layers, two front doors
bash
php artisan cachewraith:install --publish-stubs
# edit stubs/cachewraith-template/**
php artisan cachewraith:install --force

app/
├── Http/
│   ├── Controllers/Web/
│   │   ├── Auth/LoginController.php      session auth — skipped if you have Breeze etc.
│   │   ├── DashboardController.php
│   │   └── ItemController.php            the same seven decisions as the API's
│   └── Requests/Web/
│       ├── LoginRequest.php
│       ├── StoreItemRequest.php          a sibling of V1's, not a reuse
│       └── UpdateItemRequest.php
└── Support/
    └── Money.php                         decimals ↔ integer minor units, in one place

resources/views/
├── layouts/app.blade.php                 the one layout; no {!! !!} anywhere
├── partials/{alerts,field-error,pagination}.blade.php
├── auth/login.blade.php
├── dashboard.blade.php
├── items/{index,create,edit,show,_form}.blade.php
└── errors/{403,404,419,429,500,503}.blade.php   standalone; touch no session

public/vendor/cachewraith/app.css         no npm, no Vite, no CDN
routes/web_ui.php                         your routes/web.php is never touched

tests/
├── Feature/Web/{LoginTest,ItemPageTest}.php
└── Unit/MoneyTest.php
docs/WEB.md                               pages, session hardening, CSP, styling