-
-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Setup
Get Laravel Arc up and running in your Laravel application in just a few minutes.
- PHP: 8.3 or higher
- Laravel: 10.x or 11.x
- Composer: Latest version recommended
composer require grazulex/laravel-arc
php artisan vendor:publish --provider="Grazulex\LaravelArc\LaravelArcServiceProvider" --tag="config"
This creates config/arc.php
with default settings.
Laravel Arc follows Laravel conventions. Create your YAML definitions in:
resources/
βββ arc/
βββ user.yaml
βββ product.yaml
βββ nested/
βββ address.yaml
The default configuration works out of the box, but you can customize it in config/arc.php
:
<?php
return [
/*
|--------------------------------------------------------------------------
| Default DTO Namespace
|--------------------------------------------------------------------------
| The default namespace for generated DTOs when not specified in YAML
*/
'default_namespace' => 'App\\DTOs',
/*
|--------------------------------------------------------------------------
| Default Output Directory
|--------------------------------------------------------------------------
| Where generated DTO files will be saved
*/
'output_path' => app_path('DTOs'),
/*
|--------------------------------------------------------------------------
| YAML Definitions Path
|--------------------------------------------------------------------------
| Default location for YAML definition files
*/
'definitions_path' => resource_path('arc'),
/*
|--------------------------------------------------------------------------
| Field Transformers
|--------------------------------------------------------------------------
| Enable automatic field transformation
*/
'enable_transformers' => true,
/*
|--------------------------------------------------------------------------
| Validation Integration
|--------------------------------------------------------------------------
| Auto-generate Laravel validation rules
*/
'auto_validation' => true,
];
Verify your installation by running:
php artisan arc:list
You should see available Arc commands:
Available commands:
arc:generate Generate DTO from YAML definition
arc:list List all available YAML definitions
arc:validate Validate YAML definition syntax
After installation, your project structure should look like:
your-laravel-app/
βββ app/
β βββ DTOs/ # Generated DTO classes (auto-created)
βββ config/
β βββ arc.php # Configuration file (optional)
βββ resources/
β βββ arc/ # YAML definitions directory
βββ vendor/
βββ grazulex/laravel-arc/ # Package files
Create a simple test to verify everything works:
mkdir -p resources/arc
Create resources/arc/test.yaml
:
header:
class: TestDto
namespace: App\DTOs
fields:
message:
type: string
required: true
php artisan arc:generate resources/arc/test.yaml
use App\DTOs\TestDto;
$dto = TestDto::from(['message' => 'Hello Laravel Arc!']);
echo $dto->message; // "Hello Laravel Arc!"
If you encounter permission errors:
sudo chown -R $USER:$USER app/DTOs
chmod -R 755 app/DTOs
Ensure your composer.json
has the correct PSR-4 autoloading:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"App\\DTOs\\": "app/DTOs/"
}
}
}
Run composer dump-autoload
after changes.
If generated classes aren't found:
- Check the namespace in your YAML matches your autoloader
- Run
composer dump-autoload
- Clear Laravel cache:
php artisan cache:clear
β Installation Complete!
Now you're ready to:
- Create Your First DTO - Build your first DTO in 5 minutes
- Understand YAML Structure - Learn the schema basics
- Explore Field Types - See all available field types
Need help? Check the troubleshooting guide above or refer to our examples.
Laravel Arc - Generate Type-Safe DTOs from YAML Definitions
π Home | π Get Started | π Examples | βοΈ Config
From YAML to Type-Safe Code - Made with β€οΈ for the Laravel community
π Home
- π Understanding YAML Structure
- π·οΈ Field Types
- π Field Transformers
- π Behavioral Traits
YAML β DTO β Type-Safe Code
Laravel Arc transforms your YAML definitions into powerful PHP DTOs with automatic validation, field transformers, and behavioral traits.
- π Get Started - Create your first DTO in 5 minutes
- π All Examples - Copy-paste ready examples
- β‘ Commands - CLI reference