1. Intro & Setup
Welcome to the Laravel API course! Get ready to dive into the exciting world of building APIs with Laravel, the powerful and flexible PHP framework.
15:57
2. Cleaning up Laravel
Ready to supercharge your Laravel project for an API-first approach? Let’s dive into optimizing and cleaning it up to make it lightning-fast and ultra-efficient!
16:19
3. Data Modeling
When building an API, mastering the art of structuring your data and defining dynamic relationships between various entities is absolutely essential in Laravel 11.
24:27
4. API Design
When you design an API, it’s absolutely crucial to understand that every API should have a meaningful purpose!
33:09
5. Authentication & Authorization
Say goodbye to the hassle of manually crafting every single detail, and say hello to a streamlined, efficient process that keeps your endpoints vividly documented and ready to go!
14:15
6. Rate Limiting
When it comes to managing API requests, rate limiting is a key player. You don’t want to open the floodgates and let users bombard your API with endless requests.
8:24
7. API Versioning
API versioning might sound like a minor detail at first, but trust me, it's one of those decisions that can make or break the future usability of your API.
22:22
8. Pagination
When you're handling requests that could return extensive lists of resources, it's essential to implement pagination to ensure your responses are manageable and user-friendly.
11:43
9. API Standards
API standards, while useful, aren’t the be-all and end-all. What often takes precedence is discoverability and consistency in your API design.
26:17
10. Handling Errors
Today, we'll explore how to leverage Laravel 11’s error handling system by implementing the API Problem Specification and enhancing it with custom packages to provide consistent, informative error responses.
26:49
11. Write Operations
Let’s explore the steps to manage resources in a Laravel 11 API, focusing on creating, validating, updating, and deleting resources. We’ll use a real-world approach to ensure clarity and usability.
29:30
12. Internationalization
In our previous video, we dove deep into handling write operations—everything from data validation and authorization to deciding between synchronous and asynchronous processing.
11:44
13. Caching Data
In our previous video, we dove deep into handling write operations—everything from data validation and authorization to deciding between synchronous and asynchronous processing.
18:08
14. Basic Security
When it comes to API security, think of it not as a threat but as an opportunity—a chance to build robust, multilayered defenses around your API.
9:53
15. Cache Requests
In Laravel 11, we can take advantage of built-in HTTP features to manage our cache more effectively, streamlining both the response time and the overall user experience.
8:40
16. Scheduling tasks & Sending requests
When working on a Laravel API, the task scheduling system plays a significant role in automating background jobs.
40:33
17. Notifications
Whether you're building a ping service or any application that requires user communication, you’ll likely need to notify users when certain actions occur, such as a service failure.
15:57
18. Monitoring and Logging
When you're developing APIs, it's important to have a clear picture of how your API is performing in real-time.
21:33
19. Testing
When you're developing APIs or any web-based product using Laravel 11, testing plays a crucial role in ensuring that your application behaves as expected.
18:01
20. API Platform
When it comes to building web applications, Laravel has long been a go-to framework for many developers. It's a robust framework, especially for full-stack applications.
17:16
21. Feature Flags
When it comes to building web applications, Laravel has long been a go-to framework for many developers. It's a robust framework, especially for full-stack applications.
11:05
22. Web Sockets
When you're working with APIs, there's a common misconception that WebSockets aren't relevant.
9:58
23. Search API
When you're building APIs, one key feature that often gets overlooked is search. That's what we’ll explore today using TypeSense(https://typesense.org/), a powerful open-source search engine.
15:30
24. Documenting your API
By default, API Platform will give you an OpenAPI specification (currently version 3.1). This standard format allows your API to be easily understood by machines and developers alike.
07:06
API Design
When you design an API, it’s absolutely crucial to understand that every API should have a meaningful purpose! You don't just build an API for the fun of it; you build it because it tackles a specific business challenge head-on. In this exciting chapter of our Laravel 11 course, we'll take a thrilling break from coding to dive deep into API design, a crucial cornerstone of any high-powered API platform. Let's dive into the exciting world of API design and discover the best approach that perfectly matches your needs!
Approaches to API Design
Within the dynamic space of the API industry, there are numerous approaches, but one stands above the rest with excitement: API Design First! Here, you create your API and get stakeholder approval before jumping into development. This proactive approach is a staple in larger organizations where teamwork is essential, and having a clear plan ensures smooth sailing throughout the process. But hey, if you’re in a smaller, nimble setup, why not go for a more dynamic, iterative approach? Instead of getting bogged down with design right away, dive into the action and think about how your API will actually be used!
- What problems is it solving?
- How will it be used?
- What are the key functionalities?
Understanding the Purpose of Your API
Every API should have an unmistakable and dynamic purpose. In our course, we're creating an awesome Ping API! This API keeps tabs on your web service, be it a blog, a website, a business app, or a microservice. Think of the Ping API as a vigilant watchdog, always on the lookout, ready to alert you if anything goes awry.
Key Functionalities of the Ping API
When designing the Ping API, you want to amp up the excitement with these awesome functionalities:
- Manage Registered Services: Register, update, or delete services you want to monitor.
- Manage Credentials: Secure your API with tokens and update them as needed.
- Schedule Checks: Automate the monitoring of your service by scheduling checks.
- Read Reports and Receive Alerts: Get notifications if your service is down and view reports summarizing performance and uptime.
Designing the Endpoints
With these awesome functionalities in mind, let's dive into the super cool endpoints we need. We're blending the power of CRUD (Create, Read, Update, Delete) with the dynamism of behavior-driven design.
- Manage Services: A CRUD-style approach for registering and managing services.
- Manage Credentials: Similar to managing services but involves handling API tokens.
- Schedule Checks: Allows setting up, pausing, or stopping monitoring tasks.
- Reports and Alerts: This is more behavior-driven. It focuses on actions like generating reports or triggering alerts rather than just CRUD operations.
CRUD Resources vs. Behavior Resources
It’s essential to differentiate between CRUD resources and behavior-driven resources when designing your API:
- CRUD Resources: Examples include services and credentials. These are straightforward entities where operations like create, read, update, and delete apply.
- Behavior Resources: Examples include reports and alerts. These are more dynamic, requiring you to think about user actions and workflows rather than just data manipulation.
Creating the API Routes
Let's jump right in and sketch out our routes to see how everything fits together seamlessly! We're going to harness the full power of Laravel 11’s dynamic routing capabilities to define our stellar endpoints:
// Route group for managing services
Route::prefix('services')->as('services:')->group(static function (): void {
Route::get('/', Services\IndexController::class)->name('index');
Route::post('/', Services\StoreController::class)->name('store');
Route::get('/{service}', Services\ShowController::class)->name('show');
Route::patch('/{service}', Services\UpdateController::class)->name('update');
Route::delete('/{service}', Services\DeleteController::class)->name('delete');
});
// Route group for managing credentials
Route::prefix('credentials')->as('credentials:')->group(static function (): void {
Route::get('/', Credentials\IndexController::class)->name('index');
Route::post('/', Credentials\StoreController::class)->name('store');
});
// Route group for scheduling checks
Route::prefix('checks')->as('checks:')->group(static function (): void {
Route::post('/', Checks\StoreController::class)->name('store');
Route::delete('/{check}', Checks\DeleteController::class)->name('delete');
});
// Route group for reports
Route::prefix('reports')->as('reports:')->group(static function (): void {
Route::get('/reports', Reports\IndexController::class)->name('index');
Route::post('/reports', Reports\StoreController::class)->name('store');
});
Building Controllers
For each route, we need to create an invokable controller.
- App\Http\Controllers\Services*: Handles all operations related to services, such as listing all services, adding a new service, updating an existing service, or deleting a service.
- App\Http\Controllers\Credentials*: Manages credentials, including listing and creating credentials.
- App\Http\Controllers\Checks*: Manages the scheduling and rescheduling of checks.
- App\Http\Controllers\Reports*: Handle all reporting and alert functionalities.
Moving Towards Testing
Once your API design is in place, it's GO TIME! The next step is to dive into testing. Testing is your ticket to ensuring that your API kicks butt, behaves like a superstar, and meets all those design requirements. Here are some key areas to focus on when testing:
- Authentication and Authorization: Ensure that only authenticated users can access certain endpoints.
- Response Structure: Verify that the API responses conform to the expected structure.
- Error Handling: Check how the API handles different types of errors, such as invalid input or unauthorized access.
- Pagination: Make sure that the API supports pagination where applicable.
- Performance: Test the API’s performance under various loads to ensure it can handle expected traffic levels. API design is an exciting journey beyond just defining endpoints and writing code; it’s all about diving deep into your users' needs and crafting an interface that hits the sweet spot with them!