PHP code example of lswl / laravel-api
1. Go to this page and download the library: Download lswl/laravel-api 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/ */
lswl / laravel-api example snippets
// 发布所有文件
php artisan vendor:publish --tag=lswl-api
// 只发布配置文件
php artisan vendor:publish --tag=lswl-api-config
// 只发布迁移文件
php artisan vendor:publish --tag=lswl-api-migrations
// route
Route::get('tests', 'TestController@index');
// controller
use Lswl\Api\Controllers\BaseController;
use \Lswl\Api\Traits\ResourceControllerTrait;
class TestController extends BaseController
{
use ResourceControllerTrait;
}
// service
use \Lswl\Api\Services\BaseService;
class TestService extends BaseService
{
public function index()
{
$this->success('this is tests');
}
}