PHP code example of grazulex / laravel-atlas

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

    

grazulex / laravel-atlas example snippets


use LaravelAtlas\Facades\Atlas;

// Scan specific component types - all 16 available types
$modelData = Atlas::scan('models');
$routeData = Atlas::scan('routes');
$commandData = Atlas::scan('commands');
$serviceData = Atlas::scan('services');
$notificationData = Atlas::scan('notifications');
$middlewareData = Atlas::scan('middlewares');
$formRequestData = Atlas::scan('form_requests');
$eventData = Atlas::scan('events');
$controllerData = Atlas::scan('controllers');
$resourceData = Atlas::scan('resources');
$jobData = Atlas::scan('jobs');
$actionData = Atlas::scan('actions');
$policyData = Atlas::scan('policies');
$ruleData = Atlas::scan('rules');
$listenerData = Atlas::scan('listeners');
$observerData = Atlas::scan('observers');

// Export to different formats
$jsonOutput = Atlas::export('models', 'json');
$htmlReport = Atlas::export('routes', 'html');
$htmlReport = Atlas::export('events', 'blade');
$pdfDocument = Atlas::export('commands', 'pdf');

use LaravelAtlas\Facades\Atlas;

// Model architecture mapping
$modelData = Atlas::scan('models', [
    'as::scan('routes', [
    '
    '
    ';

// Middleware mapping
$middlewareData = Atlas::scan('middlewares', [
    'as::scan('events', [
    'Atlas::scan('resources');
$jobData = Atlas::scan('jobs');
$actionData = Atlas::scan('actions');
$policyData = Atlas::scan('policies');
$ruleData = Atlas::scan('rules');
$listenerData = Atlas::scan('listeners');
$observerData = Atlas::scan('observers');

use LaravelAtlas\Facades\Atlas;

// Export specific types to different formats
$jsonOutput = Atlas::export('models', 'json');
$htmlReport = Atlas::export('routes', 'html');
$htmlReport = Atlas::export('events', 'blade');
$pdfDocument = Atlas::export('commands', 'pdf');

use Tests\TestCase;
use LaravelAtlas\Facades\Atlas;

class ArchitectureTest extends TestCase
{
    /** @test */
    public function controllers_follow_naming_conventions(): void
    {
        $controllersData = Atlas::scan('controllers');
        
        foreach ($controllersData['data'] as $controller) {
            $this->assertStringEndsWith('Controller', $controller['name']);
        }
    }

    /** @test */
    public function models_have_proper_relationships(): void
    {
        $modelsData = Atlas::scan('models', ['tarts_with($route['uri'], 'api/'));
            
        foreach ($apiRoutes as $route) {
            $this->assertContains('api', $route['middleware']);
        }
    }
}

use LaravelAtlas\Facades\Atlas;

// Analyze specific component types
$modelAnalysis = Atlas::scan('models', [
    '  'e
]);

$serviceAnalysis = Atlas::scan('services', [
    '= Atlas::scan('middlewares', [
    'detailed reports
$allComponents = Atlas::scan('all', ['detailed' => true]);

// Export analysis results
$analysisReport = Atlas::export('all', 'markdown', [
    '

// config/atlas.php
return [
    'enabled' => env('ATLAS_ENABLED', true),
    
    'status_tracking' => [
        'enabled' => env('ATLAS_STATUS_TRACKING_ENABLED', true),
        'file_path' => env('ATLAS_STATUS_FILE_PATH', storage_path('logs/atlas_status.log')),
        'track_history' => env('ATLAS_TRACK_HISTORY', true),
        'max_entries' => env('ATLAS_MAX_ENTRIES', 1000),
    ],
    
    'generation' => [
        'output_path' => env('ATLAS_OUTPUT_PATH', base_path('atlas')),
        'formats' => [
            'json' => env('ATLAS_FORMAT_JSON', true),
            'markdown' => env('ATLAS_FORMAT_MARKDOWN', true),
            'html' => env('ATLAS_FORMAT_HTML', true),
            'blade' => env('ATLAS_FORMAT_BLADE', true),
        ],
    ],
    
    'analysis' => [
        '

use LaravelAtlas\Facades\Atlas;

// Scan specific components
$models = Atlas::scan('models');
$routes = Atlas::scan('routes');

// Export to different formats
$html = Atlas::export('all', 'html');
$html = Atlas::export('events', 'blade');
$json = Atlas::export('models', 'json');

use LaravelAtlas\Facades\Atlas;

// Generate comprehensive HTML documentation for available components
$htmlReport = Atlas::export('all', 'html');
file_put_contents('reports/architecture-review.html', $htmlReport);

// Generate PDF reports for presentations
$pdfReport = Atlas::export('all', 'pdf');
file_put_contents('reports/architecture-presentation.pdf', $pdfReport);

// Generate JSON reports for API consumption
$jsonData = Atlas::export('routes', 'json');
file_put_contents('public/api/routes.json', $jsonData);

// Generate interactive HTML reports for specific components
$servicesHtml = Atlas::export('services', 'html');
file_put_contents('public/docs/services.html', $servicesHtml);

$notificationsHtml = Atlas::export('notifications', 'html');
file_put_contents('public/docs/notifications.html', $notificationsHtml);

// Create complete documentation suite
$components = ['models', 'routes', 'commands', 'services', 'notifications', 'middlewares', 
               'form_requests', 'events', 'controllers', 'resources', 'jobs', 'actions', 
               'policies', 'rules', 'listeners', 'observers'];
foreach ($components as $component) {
    // Interactive HTML reports
    $html = Atlas::export($component, 'html');
    file_put_contents("public/atlas/{$component}.html", $html);
    
    // API-friendly JSON exports
    $json = Atlas::export($component, 'json');
    file_put_contents("api/atlas/{$component}.json", $json);
    
    // Professional PDF documentation
    $pdf = Atlas::export($component, 'pdf');
    file_put_contents("docs/pdf/{$component}.pdf", $pdf);
}

use Tests\TestCase;
use LaravelAtlas\Facades\Atlas;

class ArchitectureTest extends TestCase
{
    public function test_models_can_be_scanned(): void
    {
        $data = Atlas::scan('models');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('models', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_routes_can_be_scanned(): void
    {
        $data = Atlas::scan('routes');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('routes', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_commands_can_be_scanned(): void
    {
        $data = Atlas::scan('commands');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('commands', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_services_can_be_scanned(): void
    {
        $data = Atlas::scan('services');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('services', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_notifications_can_be_scanned(): void
    {
        $data = Atlas::scan('notifications');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('notifications', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_middlewares_can_be_scanned(): void
    {
        $data = Atlas::scan('middlewares');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('middlewares', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_form_requests_can_be_scanned(): void
    {
        $data = Atlas::scan('form_requests');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('form_requests', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_events_can_be_scanned(): void
    {
        $data = Atlas::scan('events');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('events', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_controllers_can_be_scanned(): void
    {
        $data = Atlas::scan('controllers');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('controllers', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_jobs_can_be_scanned(): void
    {
        $data = Atlas::scan('jobs');
        
        $this->assertIsArray($data);
        $this->assertArrayHasKey('type', $data);
        $this->assertEquals('jobs', $data['type']);
        $this->assertArrayHasKey('data', $data);
    }

    public function test_json_export_is_valid(): void
    {
        $json = Atlas::export('models', 'json');
        
        $decoded = json_decode($json, true);
        $this->assertIsArray($decoded);
    }

    public function test_html_export_is_valid(): void
    {
        $html = Atlas::export('models', 'html');
        
        $this->assertIsString($html);
        $this->assertStringContainsString('<html', $html);
    }

    public function test_pdf_export_is_valid(): void
    {
        $pdf = Atlas::export('models', 'pdf');
        
        $this->assertIsString($pdf);
        $this->assertStringStartsWith('%PDF', $pdf);
    }

    public function test_all_components_can_be_scanned(): void
    {
        $data = Atlas::scan('all');
        
        $this->assertIsArray($data);
        // Should contain the 16 implemented component types
        $this->assertArrayHasKey('models', $data);
        $this->assertArrayHasKey('routes', $data);
        $this->assertArrayHasKey('commands', $data);
        $this->assertArrayHasKey('services', $data);
        $this->assertArrayHasKey('notifications', $data);
        $this->assertArrayHasKey('middlewares', $data);
        $this->assertArrayHasKey('form_requests', $data);
        $this->assertArrayHasKey('events', $data);
        $this->assertArrayHasKey('controllers', $data);
        $this->assertArrayHasKey('resources', $data);
        $this->assertArrayHasKey('jobs', $data);
        $this->assertArrayHasKey('actions', $data);
        $this->assertArrayHasKey('policies', $data);
        $this->assertArrayHasKey('rules', $data);
        $this->assertArrayHasKey('listeners', $data);
        $this->assertArrayHasKey('observers', $data);
    }
}
bash
php artisan vendor:publish --tag=atlas-config
bash
php artisan atlas:export
bash
# Generate JSON output (default)
php artisan atlas:export --format=json

# Generate interactive HTML map
php artisan atlas:export --format=html

# Generate PDF documentation
php artisan atlas:export --format=pdf

# Generate Blade documentation
php artisan atlas:export --format=blade
bash
# Generate interactive HTML dashboard
php artisan atlas:export --format=html --output=public/docs/architecture.html

# Generate component-specific HTML reports
php artisan atlas:export --type=models --format=html --output=public/docs/models.html
php artisan atlas:export --type=routes --format=html --output=public/docs/routes.html
php artisan atlas:export --type=events --format=html --output=public/docs/events.html
php artisan atlas:export --type=controllers --format=html --output=public/docs/controllers.html
bash
# Generate interactive HTML dashboard
php artisan atlas:export --format=blade --output=resources/views/docs/architecture.html

# Generate component-specific HTML reports
php artisan atlas:export --type=models --format=blade --output=resources/views/docs/models.html
php artisan atlas:export --type=routes --format=blade --output=resources/views/docs/routes.html
php artisan atlas:export --type=events --format=blade --output=resources/views/docs/events.html
php artisan atlas:export --type=controllers --format=blade --output=resources/views/docs/controllers.html
bash
# Generate complete PDF architecture documentation
php artisan atlas:export --format=pdf --output=docs/architecture.pdf

# Generate component-specific PDF reports
php artisan atlas:export --type=models --format=pdf --output=docs/models.pdf
php artisan atlas:export --type=routes --format=pdf --output=docs/routes.pdf
php artisan atlas:export --type=services --format=pdf --output=docs/services.pdf
bash
# Run architecture tests in your pipeline
php artisan test --filter=ArchitectureTest

# Generate architecture reports
php artisan atlas:export --format=html --output=reports/architecture.html
php artisan atlas:export --format=json --output=reports/architecture.json
bash
# Generate complete application map
php artisan atlas:export --type=all --format=html

# Generate specific component maps
php artisan atlas:export --type=models --format=json
php artisan atlas:export --type=routes --format=html
php artisan atlas:export --type=events --format=blade
php artisan atlas:export --type=services --format=pdf