|
1 | | -# Laravel API Skeleton |
| 1 | +# Laravel 10 API Skeleton 📦 |
| 2 | +This project is a skeleton for setting up an API with Laravel. It contains several ways and architectures to build an API with Laravel. |
| 3 | + |
| 4 | +## Introduction 📖 |
| 5 | +As each API project is different, it's not easy to have a boilerplate that will cover all cases. Some APIs may need roles, others may not. |
| 6 | +Some may need to set up authentication with [Sanctum](https://laravel.com/docs/10.x/sanctum), others with [JWT](https://github.com/tymondesigns/jwt-auth), others with [Passport](https://laravel.com/docs/10.x/passport) and so on. |
| 7 | + |
| 8 | +All these cases are huge and complex. This project aims to build several skeletons that can be used when the need arises. |
| 9 | +And you'll end up building the architecture you want for your next API project. |
| 10 | + |
| 11 | +You can see here an example of a model like Vercel with [Nextjs](https://github.com/vercel/next.js), which has several sample implementations. |
| 12 | + |
| 13 | +## Getting Started 🚀 |
| 14 | +If you want to contribute to the Laravel API Skeleton repo: |
| 15 | + |
| 16 | +- Fork this repository to your GitHub account. Then clone your forked repository and cd into it. |
| 17 | +- Clone the repository |
| 18 | + ```bash |
| 19 | + git clone https://github.com/{username}/api-skeleton.git api-skeleton && cd api-skeleton |
| 20 | + ``` |
| 21 | +- In your fork, create a branch for your skeleton, e.g. `feature/authentication-with-passport`. |
| 22 | + |
| 23 | +Then, install the dependencies `composer install` |
| 24 | + |
| 25 | +## Architecture 🏗 |
| 26 | +The project has only 2 folders |
| 27 | +- `projets` the folder where all API skeletons will be stored to start an API project with Laravel |
| 28 | +- `skeleton` is the folder containing the commands to generate a skeleton once you've finished building it. |
| 29 | +
|
| 30 | +## Available Skeletons 📚 |
| 31 | +To get the list of available skeletons, run the command: |
| 32 | +
|
| 33 | +```bash |
| 34 | +./skeleton/bin/project available |
| 35 | +``` |
| 36 | +
|
| 37 | +All skeletons are available in the `projects` folder. Each skeleton is a Laravel project and containing a `composer.json` file and a `README.md` file. |
| 38 | +
|
| 39 | +
|
| 40 | +## Usage 📝 |
| 41 | +To create a new skeleton, run the following command: |
| 42 | +
|
| 43 | +> To build a skeleton, you have to base it on an existing skeleton. The `default` skeleton is the simplest. |
| 44 | +Once you've selected a skeleton, all the code in the skeleton's folder `projects/default` will be available at the root of the project, |
| 45 | +and you'll need to do another compose install to install the Laravel project's dependencies. |
| 46 | +
|
| 47 | +```bash |
| 48 | +./skeleton/bin/project use {skeleton-name} |
| 49 | +``` |
| 50 | +
|
| 51 | +Once you have built your skeleton and are satisfied with your work, you can generate a project and all the modifications you have made will be added only to the skeleton you have created. |
| 52 | +
|
| 53 | +```bash |
| 54 | +./skeleton/bin/project generate {skeleton-name} |
| 55 | +``` |
| 56 | +
|
| 57 | +This command will create a new Laravel project in the `projects` folder with the name of your skeleton. And you can publish it on packagist composer or if you like. |
| 58 | +Before pushing your branch and making a PR, you need to run the following command to reset the project to its original state. |
| 59 | +
|
| 60 | +```bash |
| 61 | +./skeleton/bin/project reset |
| 62 | +``` |
| 63 | +
|
| 64 | +## Contributing 🤝 |
| 65 | +Feel free to create any pull requests for the project. If you have any questions, please you can create an issue. |
0 commit comments