PHP code example of m3assy / laravelannotation

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

    

m3assy / laravelannotation example snippets




namespace App\Http\Controllers\Modules;

use App\Http\Controllers\Controller;

/**
 * Example For Middleware Class Annotation
 * @Auth
 */
class UserController extends Controller
{
    /**
     * Example For Middleware Method Annotation
     * @Auth
     * @ExampleAnnotationWithParameter("values") 
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return response();
    }
}



namespace App\Foundation\Annotations;

use M3assy\LaravelAnnotations\Foundation\Types\MiddlewareAnnotation;

/**
 * @Annotation
 */
class Guest extends MiddlewareAnnotation
{

}



namespace App\Foundation\Annotations;

use M3assy\LaravelAnnotations\Foundation\Types\MiddlewareAnnotation;

/**
 * @Annotation
 */
class Guest extends MiddlewareAnnotation
{
    /**
    * @return bool
    */
    public function validateGivenValue()
    {
        // Your Validation Logic Goes Here
    }
}



namespace App\Http\Controllers\Modules;

use App\Http\Controllers\Controller;

/**
 * Example For Middleware Class Annotation
 * @Auth
 */
class UserController extends Controller
{
    public $value;
    /**
     * Example For Middleware Method Annotation
     * @Auth
     * @ExampleAnnotationWithParameter("{$this->value}") 
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return response();
    }
}



namespace App\Http\Controllers\Modules;

use App\Http\Controllers\Controller;

/**
 * @Role("superadmin")
 */
class UserController extends Controller
{
    /**
     * @Permission("list-users|create-users") 
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return response();
    }
}
 php
'providers' => [
    // Service Providers
    M3assy\LaravelAnnotations\LaravelAnnotationServiceProvider::class,
],
'aliases' => [
    // Facade Aliases
    'Annotation' => M3assy\LaravelAnnotations\Facades\Annotation::class,
],
bash
  $ php artisan make:annotation Guest
bash
  $ php artisan scan:acl