
Laravel Packages
Package development, service providers, facades, publishable assets, configuration, migrations, package discovery
1What is the main difference between the register() and boot() methods of a Service Provider?
What is the main difference between the register() and boot() methods of a Service Provider?
Câu trả lời
The register() method is used to bind services to the IoC container without depending on other services, as they are not yet available. The boot() method is called after all providers have been registered, allowing access to all registered services and configuration of features that depend on them such as routes, views, or events.
2What is the recommended basic structure for a Laravel package?
What is the recommended basic structure for a Laravel package?
Câu trả lời
A well-structured Laravel package contains a src/ directory for PHP source code including the Service Provider, a config/ directory for configuration files, a composer.json with metadata and PSR-4 autoload, plus optional directories for resources like database/, resources/, and routes/. This organization facilitates maintenance and follows community conventions.
3How does package discovery work in Laravel?
How does package discovery work in Laravel?
Câu trả lời
Package discovery uses the extra.laravel section in the package's composer.json to automatically declare providers and aliases. During installation via Composer, Laravel reads this metadata and automatically registers services without manual modification of config/app.php. This feature simplifies package installation and reduces configuration errors.
How to make a configuration file publishable in a Laravel package?
What is the purpose of the mergeConfigFrom() method in a package Service Provider?
+17 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Laravel khác
PHP Basics
PHP OOP Essentials
Composer & Autoloading
Laravel Fundamentals
Laravel Routing
Blade Templates
Request & Response
Eloquent ORM Basics
Eloquent Relationships
Migrations & Schema Builder
Validation & Forms
Authentication
Authorization & Policies
API Resources & Authentication
Middleware
Service Container & DI
Queues & Jobs
Events & Listeners
Notifications & Mail
File Storage
Testing & PHPUnit
Caching
Livewire & Inertia
Eloquent Advanced
Repository Pattern
Performance Optimization
Security Best Practices
Laravel Octane
Laravel Distributed Systems
Observability & Monitoring
Deployment & DevOps
Nắm vững Laravel cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí