Stars: 207
Forks: 89
Pull Requests: 23
Issues: 10
Watchers: 10
Last Updated: 2023-04-19 21:00:53
Simple example of a API REST with Laravel 9.x
License: MIT License
Languages: PHP, Shell, Blade, JavaScript
Simple example of a REST API with Laravel 9.x
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install or composer install
$ cp .env.example .env
$ php artisan key:generate
$ php artisan migrate --seed
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X GET http://127.0.0.1:8000/api/books
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X GET http://127.0.0.1:8000/api/books/:id
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X POST -d '{"title":"Foo bar","price":"19.99","author":"Foo author","editor":"Foo editor"}' http://127.0.0.1:8000/api/books
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X PUT -d '{"title":"Foo bar","price":"19.99","author":"Foo author","editor":"Foo editor"}' http://127.0.0.1:8000/api/books/:id
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X DELETE http://127.0.0.1:8000/api/books/:id
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X GET http://127.0.0.1:8000/api/books?page=:number_page -H 'Authorization:Basic username:password or email:password'
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X GET http://127.0.0.1:8000/api/books -H 'Authorization:Basic username:password'
$ curl -H 'content-type: application/json' -H 'Accept: application/json' -v -X GET http://127.0.0.1:8000/api/books -H 'Authorization:Basic email:password'
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/opt \
-w /opt \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
./vendor/bin/sail up