PHP code example of novadaemon / larafeat

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

    

novadaemon / larafeat example snippets




namespace App\Features;

use Illuminate\Http\Request;
use Novadaemon\Larafeat\Feature;

class MyAwsomeFeature extends Feature
{
    public function handle(Request $request)
    {
        $order = $request->input('order');

        //...
    }
}



namespace Tests\Feature;

use Tests\TestCase;
use App\Features\MyAwsomeFeature;

class MyAwsomeFeatureTest extends TestCase
{
    public function test_my_awsome_feature()
    {
        $this->markTestIncomplete();
    }
}



namespace Tests\Feature;

test('example', function () {
    $response = $this->get('/');

    $response->assertStatus(200);
});



namespace App\Controllers;

use Novadaemon\Larafeat\Controllers\Controller;
use App\Features\MyAwesomeFeature;

class MyController extends Controller
{
    public function get()
    {
        return $this->serve(MyAwesomeFeature::class);
    }
}



namespace App\Features;

use Illuminate\Http\Request;
use Novadaemon\Larafeat\Feature;

class MyAwsomeFeature extends Feature
{
    public function __construct(private string $name)
    {
    }

    public function handle(Request $request)
    {
        $name = $this->name;

        //...
    }
}




namespace App\Controllers;

use Novadaemon\Larafeat\Controllers\Controller;
use App\Features\MyAwesomeFeature;

class MyController extends Controller
{
    public function get()
    {
        return $this->serve(MyAwesomeFeature::class, ['name' => 'Jesús']);
    }
}



namespace App\Features;

use App\Jobs\GreetingJob;
use Illuminate\Http\Request;
use Novadaemon\Larafeat\Feature;

class MyAwsomeFeature extends Feature
{
    public function __construct(private string $name)
    {
    }

    public function handle(Request $request)
    {
        return $this->run(new GrettingJob($this->name));
    }
}
bash
php artisan make:feature MyAwesomeFeature
bash
php artisan make:feature MyAwesome