xtend-packages / rest-presenter

Kickstart your Laravel development with our API Starter Kits & Generators.
https://rest-presenter.com
MIT License
59 stars 5 forks source link

RESTPresenter Setup Command (Customisations) #3

Closed adam-code-labx closed 5 months ago

adam-code-labx commented 5 months ago

Initial Setup:

  1. Running the Setup Command: Execute the setup command to initiate the process. This action will generate the XtendRESTPresenterServiceProvider, allowing you to register the desired kits effortlessly.

  2. API Structure Creation: Upon running the setup command, the script automatically constructs the API structure within your application. This step facilitates the option to override resource presenters or actions as per your requirements.

By following these steps, you can swiftly integrate our starter kits into your project and begin leveraging their functionalities without the need for extensive customisation.

For example:

namespace App\Providers;

use XtendPackages\RESTPresenter\Facades\RESTPresenter;
use XtendPackages\RESTPresenter\StarterKits\Auth\Breeze\BreezeApiKitServiceProvider;
use XtendPackages\RESTPresenter\StarterKits\Lunar\LunarApiKitServiceProvider;

class XtendRESTPresenterServiceProvider extends AppServiceProvider
{
    public function register(): void
    {
        RESTPresenter::register($this->app)
            ->starterKits([
                BreezeApiKitServiceProvider::class,
                LunarApiKitServiceProvider::class,
            ]);
    }
}
adam-code-labx commented 5 months ago

Setup Command Explanation:

When invoking the setup command the script provides prompts to guide the user through the process. Here's a breakdown of what it does:

  1. Checking for Previous Updates: The command first checks if you've previously run the update. If a kit has already been updated, it skips it to prevent redundant operations.

  2. Updating Kits: For kits that haven't been updated, the script copies the main resources of the kit to your application. Additionally, it extends the kit classes, ensuring that your application is equipped with the latest changes and improvements.

This update mechanism streamlines the process of keeping your application up-to-date with the latest kit enhancements, while also minimising unnecessary operations through intelligent skipping of previously updated kits.