- How does CND API Maker Core integrate with Laravel’s Eloquent ORM?
- The package is designed to work seamlessly with Eloquent models, automatically generating controllers, routes, and Form Request validation tied to your model’s schema. It leverages Laravel’s built-in features like Route Model Binding and middleware integration, ensuring consistency with Eloquent’s conventions. However, it assumes Eloquent usage—custom repositories or raw SQL may require manual adjustments.
- Can I use this package for GraphQL APIs instead of REST?
- No, CND API Maker Core is REST-first and enforces HTTP method conventions (GET, POST, PUT, DELETE) for resource endpoints. While it won’t work natively with GraphQL, you could adapt its templating system for GraphQL resolvers, though this would require customization beyond the package’s core functionality.
- What Laravel versions does this package support?
- The package targets modern Laravel versions (8.x and 9.x) due to its reliance on features like Form Requests, Route Model Binding, and Eloquent’s query builder. Check the package’s `composer.json` or GitHub for exact version requirements, but it’s unlikely to support Laravel 7 or below without compatibility layers.
- Does it support API Resources for custom JSON responses?
- By default, the package standardizes responses using its own conventions, which may conflict with Laravel’s API Resources. You can override its response templates or extend its generators to integrate API Resources, but this requires manual configuration to align both systems.
- How do I scaffold a new API endpoint for an existing Eloquent model?
- Use the package’s CLI commands or API to generate a controller, routes, and Form Request for your model. For example, run `php artisan cnd:api-maker:make [ModelName]` (check the exact command in the docs) to auto-create the scaffold. The package handles naming conventions, validation rules, and HTTP methods automatically.
- Will this package work with Laravel Sanctum or Passport for authentication?
- The package doesn’t include built-in auth middleware, but you can manually bind Sanctum/Passport middleware to the generated routes or controllers. It’s designed to integrate with Laravel’s middleware system, so adding auth is straightforward—just ensure your middleware is registered in the correct HTTP kernel or controller.
- Can I customize the JSON response structure or HTTP status codes?
- Yes, the package allows template overrides for responses and status codes. You can modify its stubs or extend its generators to enforce your own JSON schemas or custom status logic. Check the documentation for template paths and configuration options.
- Is there a way to test the generated API endpoints without deploying?
- The package doesn’t include built-in testing utilities, but you can use Laravel’s built-in testing tools (e.g., `Http::fake()` or Pest/PHPUnit) to test the generated routes and controllers. Since it follows Laravel conventions, standard testing practices apply—mock dependencies like Form Requests or Eloquent queries as needed.
- What if I need to add custom business logic to the generated controllers?
- The package generates clean, modular controllers with hooks for custom logic. You can extend the base controller or override methods like `store()`, `update()`, or `show()` in your own controller class. Its templating system is designed to preserve your customizations across future scaffoldings.
- Are there alternatives to CND API Maker Core for Laravel API scaffolding?
- Yes, alternatives include **Laravel API Scaffolding** (by Spatie), **Inertia.js + Laravel** for SPA APIs, or **APIato** for more opinionated REST scaffolding. Unlike CND API Maker, some focus on GraphQL (e.g., **Lighthouse**), while others prioritize performance (e.g., **Laravel Octane**). Evaluate based on your need for REST conventions, Eloquent integration, or hybrid architectures.