When to create a package
Create a new package when you’re building a self-contained business domain with its own models, routes, and business logic. Examples:- Reporting module
- Notification system
- Integration with a third-party service
Step 1: Create the directory structure
Step 2: Create composer.json
Step 3: Create the ServiceProvider
Step 4: Define routes
Step 5: Create the model
Step 6: Create migration
Step 7: Create policy
Step 8: Create controller and service
Follow the Service Layer pattern — keep controllers thin and delegate to services.Step 9: Register the package
Add to the rootcomposer.json:
Step 10: Run migrations
Package checklist
-
composer.jsonwith proper namespace and autoload - ServiceProvider registered via Laravel auto-discovery
- Routes use
exowpee.teamsplus the complete access group for their context - Models using
KsuidTrait - Policies using
BeforePolicyFilterTrait - FormRequests extending
RestApiFormRequest - Resources for response formatting
- Migrations with
company_id/organization_idcolumns - Translations in
enandfr - Contract interface for cross-package communication