PHP code example of annotation / larscan

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

    

annotation / larscan example snippets


use Annotation\Scannable\Attributes\Scan;
use Annotation\Scannable\Attributes\ScanFile;
use Annotation\Scannable\Attributes\ScanNamespace;
use Annotation\Scannable\Attributes\ScanPath;
use Annotation\Scannable\Attributes\ScanPackageNamespace;

public function scan(): void
{
    // ScanPackageNamespace
    $scan = new ScanPackageNamespace(['GuzzleHttp']);
    
    // ScanNamespace
    $scan = new ScanNamespace(['Illuminate\Support\Arr']);
    $scan = new ScanNamespace(['Illuminate\Support*']);
    
    // ScanPath
    $scan = new ScanPath(__DIR__.'/../Http/');
    $scan = new ScanPath(new \RecursiveDirectoryIterator(__DIR__.'/../Http/Controllers'));
    
    // ScanFile
    $scan = new ScanFile(__FILE__);
    $scan = new ScanFile(new \SplFileInfo(__DIR__ . '/AppServiceProvider.php'));
    
    // Scan
    $scan = new Scan('Illuminate\Support\Arr');
    $scan = new Scan(['Illuminate\Support\Arr']);
    $scan = new Scan(new \ReflectionClass('Illuminate\Support\Arr'));
}

use Annotation\Scannable\Attributes\Scan;
use Annotation\Scannable\Attributes\ScanFile;
use Annotation\Scannable\Attributes\ScanNamespace;
use Annotation\Scannable\Attributes\ScanPath;
use Annotation\Scannable\Attributes\ScanPackageNamespace;
use Rfc\Scannable\Contracts\Scannable;

#[ScanPackageNamespace(['GuzzleHttp'])]

#[ScanNamespace(['Illuminate\Support\Arr'])]
#[ScanNamespace(['Illuminate\Support*'])]

#[ScanPath(__DIR__.'/../Http/')]
#[ScanPath(new \RecursiveDirectoryIterator(__DIR__.'/../Http/Controllers'))]

#[ScanFile(__FILE__)]
#[ScanFile(new \SplFileInfo(__DIR__ . '/AppServiceProvider.php'))]

#[Scan('Illuminate\Support\Arr')]
#[Scan(['Illuminate\Support\Arr'])]
#[Scan(new \ReflectionClass('Illuminate\Support\Arr'))]
class AppServiceProvider extends ServiceProvider implements Scannable
{
    //
}

use Annotation\Scannable\Attributes\ScanNamespace;
use Annotation\Scannable\Attributes\ScanPackageNamespace;
use Annotation\Scannable\Contracts\Scanner;
use Annotation\Scannable\Facades\Scan;

public function scan(Scanner $scan): void
{
    $namespace = $scan->using(ScanPackageNamespace::class, function (ScanPackageNamespace $scanNamespace) {
        return $scanNamespace->getReflectionClass();
    });
    //dump($namespace);
    $namespace = Scan::using(ScanNamespace::class, function (ScanNamespace $namespace) {
        return $namespace->getNamespace();
    });
    //dump($namespace);
}