Creating Your First Application
Now that Bejibun is installed, it’s time to build your first application. In this guide, you’ll create a simple User Management API while learning the framework’s core concepts:- Routing
- Controllers
- Request Handling
- Validation
- Models
- Database Operations
What We Are Building
We’ll create a small API that allows users to:Step 1: Create a New Project
If you haven’t already created a project:Step 2: Generate a User Model
Models represent database tables. Generate a model:Step 3: Create a Migration
Database tables are managed through migrations. Generate a migration:users table in your database.
Step 4: Generate a Controller
Controllers contain your application’s request handling logic. Generate a controller:Step 5: Register Routes
Open your routes file:Step 6: Implement the Controller
Let’s add the controller methods.Step 7: Add Validation
Accepting user input without validation is dangerous. Generate a validator:Step 8: Test the API
Create a user:Understanding the Request Flow
When a request reaches your application, it passes through several layers.Organizing Business Logic
As applications grow, controllers should remain thin. Avoid:Error Handling
Database lookups may fail. Example:Using Resource Controllers
For standard CRUD endpoints, Bejibun may provide resource routing. Instead of:What You Have Learned
In this guide, you:- Created a Bejibun project
- Generated a model
- Created a migration
- Built a controller
- Registered routes
- Added validation
- Performed database operations
- Tested an API endpoint
Common Next Steps
After completing this tutorial, developers typically move on to:- Authentication
- Authorization
- Relationships
- File Uploads
- Caching
- Background Jobs
- API Documentation
Next Steps
Continue to:- Project Structure
- Configuration
- Environment Variables
- Request Lifecycle
