saeed / custom-api
Package for make restfull api project
Requires
- illuminate/support: ^10.0
This package is auto-updated.
Last update: 2025-08-15 10:09:59 UTC
README
To install and set up the Saeed Custom API package, please follow the steps below:
Step 1: Install the Package
You can install the package using Composer with the following command:
composer require saeed/custom-api:dev-main
Step 2: Autoload Configuration
In your composer.json file, under the autoload section, add the following entry for PSR-4 autoloading:
"autoload": { "psr-4": { //... "Saeed\\CustomApi\\": "packages/saeed/customApi/src/" } }
Run the following command to update the autoloader:
composer dump-autoload
Step 3: Service Provider Registration
Next, you need to register the service provider in your application's configuration. Open the config/app.php file and add the provider to the providers array:
'providers' => [ // Other service providers... \Saeed\CustomApi\CustomApiServiceProvider::class, ],
Step 4: Creating Form Requests and Services
You can create form requests and logical services using the following Artisan commands:
Create API Request
To create a form request, run:
php artisan make:apiRequest {name}
Create Logic Service
To create a logic service, use:
php artisan make:apiService {name}
Step 5: Controller Setup
In your controller, you can inject the service as follows:
public function __construct(private Name $name) {}
Step 6: Using the Logic Service
You can use the logic service like this:
$result = $this->testService->showTests();
Step 7: Using the API Response
To format your API response, use the following code:
return ApiResponse::withMessage('Your message here') ->withData(TestResource::collection($result->data)) ->build() ->apiResponse();
Conclusion
These instructions should help you get started with the Saeed Custom API package. If you have any questions or issues, feel free to reach out for support!