Laravel blog app. Note: This is a WIP Repository.
- Type
git clone https://github.com/pfieffer/LaravelBlogApp.git
orgit clone [email protected]:pfieffer/LaravelBlogApp.git
to clone the repository. - CD to
LaravelBlogApp
- Type
composer install
- Type
composer update
- Copy .env.example to .env
- To use MySQL database, set the following in .env file :
- set DB_CONNECTION
- set DB_DATABASE
- set DB_USERNAME
- set DB_PASSWORD
- Run DB migrations and seeders: Type
php artisan migrate --seed
to create and populate tables. This will seed the datbase with some sample posts and a user. (User Credentials: email: [email protected], password: test@123) - Run
php artisan key:generate
to generate application keys. - Run
php artisan passport:install
to setup Passport for api authentication. - You may need to run
php artisan storage:link
to see the blog post images. - Also do put an image file with name
noimage.jpg
insidestorage/app/public/cover_images/
directory.
- Open your favorite REST client like POSTMAN or insomnia.
GET
request on<localhosts_or_your_ip_address_and_port>/api/v1/allposts
to see all postsPOST
request on<localhosts_or_your_ip_address_and_port>/api/v1/login
with the following JSON body:
{
"email":"[email protected]",
"password":"test@123"
}
- After the login, you will obtain an
api_token
which you can use to CRUD the post from api. - An example is to see all the post for a user:
GET
request to<localhosts_or_your_ip_address_and_port>/api/v1/posts
with aAuthorization
header having valueBearer <api_token_obtained_on_loggin_in>