1. Go to this page and download the library: Download bleuren/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/ */
bleuren / laravel-api example snippets
use App\Contracts\UserServiceInterface;
class UserController extends Controller
{
protected $userService;
public function __construct(UserServiceInterface $userService)
{
$this->userService = $userService;
}
public function index()
{
return $this->userService->all();
}
public function show($id)
{
return $this->userService->find($id);
}
// ... other methods
}
use Bleuren\LaravelApi\BaseRepository;
use App\Models\User;
class UserRepository extends BaseRepository
{
public function __construct(User $model)
{
parent::__construct($model);
}
// Add custom methods here
}
use Bleuren\LaravelApi\BaseService;
use App\Contracts\UserRepositoryInterface;
class UserService extends BaseService
{
public function __construct(UserRepositoryInterface $repository)
{
parent::__construct($repository);
}
// Add custom methods here
}