⭐️ 在 Laravel 中构建您不会讨厌的 API。
Laravel API Starter streamlines modern API development in Laravel. This carefully crafted starter project is designed to simplify and expedite your journey in building APIs with Laravel. Serving as a launchpad for your next project, it equips you with a comprehensive set of ready-to-use tools commonly required in API development. Save time and kickstart your Laravel API project effortlessly with Laravel API Starter.
Laravel API Starter comes included with...
git clone https://github.com/gentritabazi/laravel-api-starter && cd laravel-api-starter && sh ./scripts/install.shThis will:
.env file in the project root.APP_KEY.public/storage to storage/app/public.Now you just need to update your .env file as needed and install passport (check below how to install passport).
First clone the repository.
git clone https://github.com/gentritabazi/laravel-api-starterInstall dependencies.
composer installCopy the .env file an create and application key.
cp .env.example .env && php artisan key:generateCreate a symbolic link from public/storage to storage/app/public.
php artisan storage:linkMigrate the tables.
php artisan migrateProject comes with Passport include as the default authenticatin method. You should now install it using this command.
php artisan passport:installCopy-paste the generated secrets and IDs into your .env file like so.
PERSONAL_CLIENT_ID=1
PERSONAL_CLIENT_SECRET=SECRET_HERE
PASSWORD_CLIENT_ID=2
PASSWORD_CLIENT_SECRET=SECRET_HEREIf you want to save it elsewhere or change the naming be sure to modify the LoginService in infrastructure/Auth/Services/LoginService.php
If you want to use docker to install composer dependencies use this script.
You can quickly test if the authentication works by creating an user using the include command.
php artisan users:add {first_name} {last_name} {email} {password}
Example: php artisan users:add Gentrit Abazi [email protected] mypasswordNow serve your application and try to request a token using cURL
php artisan serve
curl -X POST http://localhost:8000/login -H 'Content-Type:application/json' -d '
{
"email": "[email protected]",
"password": "mypassword"
}'This should return a token.
{
"access_token": "TOKEN_HERE",
"expires_in": 600
}Now try to request all users GET /users using the newly issued token.
…This should return a response like so
{
"users": [
{
"id":1,
"first_name": "Gentrit",
"last_name": "Abazi",
"email": "[email protected]",
"name": "Gentrit Abazi"
}
]
}You can refresh a new token by requesting POST /login/refresh and logout using POST /logout.
暂无开放 Issues,或尚未同步最近议题。