This is a simple Laravel 9 application that interacts with the Kanye REST API to display random Kanye West quotes on a web page and provides an API to fetch multiple random quotes in JSON format.
- Displays 5 random Kanye West quotes on a web page.
- Allows users to refresh the quotes.
- Requires user authentication to access the quotes page.
- Provides an API endpoint to fetch a specified number of random quotes in JSON format.
- API routes are secured with token-based authentication using Laravel Sanctum.
- A cron job can be set up to periodically fetch and store quotes with a retry mechanism in case of failure.
- PHP 8.0 or higher
- Composer
- Node.js and NPM
- Laravel 9.x
- MySQL or another supported database
-
Clone the repository:
git clone https://github.com/your-username/kanye-quotes-app.git cd kanye-quotes-app
-
Install dependencies:
composer install npm install npm run dev
-
Environment setup:
Copy the
.env.example
file to.env
and update the environment variables with your database and other necessary configurations.cp .env.example .env php artisan key:generate
-
Run migrations:
php artisan migrate
-
Install Laravel Breeze (for authentication):
php artisan breeze:install npm install && npm run dev php artisan migrate
-
Install and configure Laravel Sanctum (for API authentication):
composer require laravel/sanctum php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" php artisan migrate
-
Serve the application:
php artisan serve
The application will be accessible at
http://localhost:8000
.
- Visit
http://localhost:8000/quotes
to view 5 random Kanye West quotes. - You must be logged in to access this page.
- Use the "Refresh Quotes" button to get a new set of quotes.
-
Get X random quotes (JSON):
- Endpoint:
/api/quotes/{count}
- Method:
GET
- Authentication: Requires a valid Sanctum API token.
Example request:
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/api/quotes/5
- Endpoint: