PHP code example of tetracode / ncoder

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

    

tetracode / ncoder example snippets


 'providers' => [
    Tetracode\Ncoder\NcoderBaseServiceProvider::class,
   ],
  

 protected $routeMiddleware = [

 'ncoder'=>\Tetracode\Ncoder\Http\Middleware\EncryptHttp::class,
 'xncoder'=>\Tetracode\Ncoder\Http\Middleware\ForceEncryptHttp::class,
 ]

Route::middleware('ncoder')->post('api-endpoint', 'ApiController@store');

//Force Encrypt Response
Route::middleware('xncoder')->post('api-endpoint', 'ApiController@store');

Route::group(['middleware' => ['ncoder']], function () {
    Route::post('api-endpoint', 'ApiController@store');
});

//Force Encrypt Response
Route::group(['middleware' => ['xncoder']], function () {
    Route::post('api-endpoint', 'ApiController@store');
});

class UserController extends Controller {

    public function __construct() {
        $this->middleware(['ncoder']);
    }

    public function index() {
         return response()->json(User::all());
    }
}


class UserController extends Controller {

    public function __construct() {
        $this->middleware(['xncoder']);
    }

    public function index() {
        return response()->json(User::all());
    }
}
bash
 php artisan vendor:publish --tag ncoder-config
bash
 php artisan ncoder:secret