DEV Community

dgloriaweb
dgloriaweb

Posted on

Laravel 10 API application with necessary functions pt 2.

Environment: Windows 10

Necessary prequisites (knowledge): VS Code, Composer, Terminal, Git bash, GitHub, Postman, MarkDown, XAMPP (also serves my MySql database), environmental variables (or .env), Blade, SPA, Sanctum, Passport

If you require further details, please feel free to add in comments.

Nice to know: If you don't see a change take effect, try stopping the server, and running this to clear cache and config:
php artisan config:cache
When you've made changes in your .env file, you have to stop the server, run this and restart the server, for the changes to take effect.
Same goes to route changes:
php artisan route:cache


Project Settings

There are plenty of knowledge on the Laravel documentation (https://laravel.com/docs/11.x/configuration), please feel free to explore.
I have changed the language just for safety.
'faker_locale' => 'en_UK',
My default time zone is UTC, which is correct, you may change this in config/app.php
You may change the .env APP_NAME, but don't use spaces or special characters.

Database

I use mysql, and created a local database called L10Schema (case insensitive). I am going to connect the app to this database by editing my .env file like this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=l10schema
DB_USERNAME=root
DB_PASSWORD=
Enter fullscreen mode Exit fullscreen mode

To be able to keep my database in sync at all times with my code, table schemas and fields/columns, I'm going to run
php artisan migrate
and from now on, when there is a database schema change, I repeat this.
(You can either ctrl+c to stop the php artisan serve code from running while you run this, or just open a new split command prompt and put it in there. )
To check if the migration ran successfully, open your database and see the new tables that's been created by Laravel.

Current frontend page

The page you see on http://127.0.0.1:8000/ is called a view. This is the resources\views\welcome.blade.php file, that shows where the blade frontend files should be stored if you decide to use blade for your frontend. We aren't doing frontend in this blog post.

Don't forget to git commit and git push to store your working app. From this point it is recommended to create a new branch for changes, since what works for me might not work for you.

Top comments (0)