1. Go to this page and download the library: Download rustyphp/microservice-crud 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/ */
rustyphp / microservice-crud example snippets
// Uncomment the line below to enable Facade support.
$app->withFacades();
// Uncomment the line below to enable Eloquent ORM support.
$app->withEloquent();
// Add the line below to load database config. This is
namespace App\Models;
use LushDigital\MicroServiceModelUtils\Models\MicroServiceBaseModel;
use LushDigital\MicroServiceCrud\Models\CrudModelInterface;
class Example extends MicroServiceBaseModel implements CrudModelInterface
{
/**
* {@inheritdoc}
*/
public function getValidationRules($mode = 'create', $primaryKeyValue = null)
{
// TODO: Implement getValidationRules() method.
}
}
namespace App\Http\Controllers;
use LushDigital\MicroServiceCrud\Http\Controllers\CrudController;
class ExamplesController extends CrudController {}
namespace App\Providers;
use App\Models\Example;
use Illuminate\Support\ServiceProvider;
use LushDigital\MicroServiceCrud\Observers\CrudObserver;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Add an observer to the example model.
Example::observe(CrudObserver::class);
}
}
namespace App\Http\Controllers;
use LushDigital\MicroServiceCrud\Http\Controllers\CrudController;
class ExamplesController extends CrudController
{
/**
* The model associated with the CRUD controller.
*
* @var string
*/
protected $modelBaseClass = 'NotAnExample';
}
namespace App\Http\Controllers;
use LushDigital\MicroServiceCrud\Http\Controllers\CrudController;
class ExamplesController extends CrudController
{
/**
* The model associated with the CRUD controller.
*
* @var string
*/
protected $modelNamespace = 'My\\Awesome\\Namespace';
}
namespace App\Models;
use LushDigital\MicroServiceModelUtils\Models\MicroServiceBaseModel;
class Example extends MicroServiceBaseModel
{
/**
* A list of the model attributes that can be used as cache keys.
*
* @var array
*/
protected $attributeCacheKeys = ['name'];
}