DEV Community

dgloriaweb
dgloriaweb

Posted on

Laravel 10 API application with necessary functions pt 1.

Hi, this is a step by step Laravel installation and build guide for Windows 10 with XAMPP, made in 2024, using Laravel10. I have not brought this to sections, because some steps are not necessary to do in order, and some are dispensable. I will build this as a series since this is a huge work, and your comments/issues are much better understandable if I keep the content in a single part shorter. I haven't gone into detail explaining Laravel packages like Passport, I request you not to ask me to explain why stuff work as it works, but to read the documentation. It took me several years to build a working Laravel API with OAuth, you won't be able to understand all from a single blog post. But do comment, if my explanation or flow didn't work for you, I'll do my best to fill in the gaps.

Environment: Windows 10

Necessary prequisites (knowledge): VS Code, Composer, Terminal, Git bash, GitHub, Postman, MarkDown

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


Project Local Installation

Make sure that the latest composer package manager version is installed.
In your command prompt navigate to the project containing folder, the composer will add a project folder to contain all the files here. Run this in the command line:

composer create-project laravel/laravel Laravel10_Schema

Replace Laravel10_Schema with your project name.
After a long list of packages, this should appear and the cursor:

INFO Application key set successfully.

Now your main app is ready to use. Go to the project folder:

cd Laravel10_Schema

and run VS Code, or your favourite editor. I'm using VS Code.

code .

Open the terminal, I have two splitted windows: a command prompt for running the server, and a GitBash window for version control management.

First time test of the new project:
In command prompt type
php artisan serve

Take note of the server url, you'll need this later when running API from Postman or other. Ctrl-click on the url, and this opens the website in your default browser.

Store the app in a GitHub repository:

Open your GitHub, go to new repository, add a name and a description and leave all else untouched. This should take you to a quick setup page, look for this section:
…or create a new repository on the command line

Click on the copy icon in the right corner, and paste everything into your VS Code terminal/GitBash command line. Easiest is to right click.
When you see git push -u origin main press enter once again to finish the initialisation. Now you are connected, and if you refresh GitHub, you'll se the Readme.md file contents, that is located in your project's root folder. Experiment with this, change it, once you push your changes in the main repo, this will update. Look for MarkDown to make nice Readme pages.
To update and add all files to your main branch type these in the GitBash:
git add .
git commit -am 'first'
git push
Now, when you refresh your GitHub once more, you can see the same file structure as in the VSCode navigation pane.

Top comments (0)