This is a sample repo for the Introduction to Laravel caching blog post. It has two branches:
starter
— What you should work off of if you're going through the tutorial from scratchmain
— The final version of the app with caching
Check out the PlanetScale blog for the full tutorial.
- Create a database on PlanetScale. Refer to the tutorial for full instructions.
- Clone this repo:
git clone -b starter https://github.com/hollylawly/laravel-caching
Leave off the -b starter
if you just want the final version.
- Install the dependencies:
composer install
- Copy the
.env.example
file to.env
:
mv .env.example .env
- Update the database connection with the credentials from the PlanetScale dashboard:
DB_CONNECTION=mysql
DB_HOST=<ACCESS HOST URL>
DB_PORT=3306
DB_DATABASE=<DATABASE_NAME>
DB_USERNAME=<USERNAME>
DB_PASSWORD=<PASSWORD>
MYSQL_ATTR_SSL_CA=/etc/ssl/cert.pem
- Run the migrations and seeder:
php artisan migrate
php artisan db:seed
- Start your application:
php artisan serve
- You can now view your non-cached data from the PlanetScale database in the browser at http://localhost:8000/api/quotes.