PHP code example of teksite / handler

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

    

teksite / handler example snippets


'providers' => [
    // Other Service Providers
    Teksite\Handler\ServiceProvider::class,
],

'providers' => [
    // Other Service Providers
    Teksite\Handler\ServiceProvider::class,
];

\Teksite\Handler\Actions\ServiceWrapper


 return ServiceWrapper::make()->do(function (){
    // your code
 })->ifFailed(function(){
    //in case your code failed
 })->run();


\Teksite\Handler\Services\FetchDataService

 //
 public function get(mixed $fetchData = []){
    ServiceWrapper::make()->do(function () use ($fetchData){
        FetchDataService::get(Post::class, ['title'], ...$fetchData);
    })->ifFailed(function(){
    //in case your code failed
    })->run();
 });
}



    // sucess message
    $response =ResponderServices::success('weldone' ,['post=>$post] , 201);
    
    // failed message
    $response =ResponderServices::failed('something went wrong' , ['auth'=> 'forbidden' , ...] ,500);

    // to redirct client as http response 
    $response->go();
    
    // to respone as json in api and ajax senario
    $response->reoly()

bash
php artisan vendor:publish --provider="Teksite\Handler\ServiceProvider"