
Laravel development involves more than writing controllers. The questions that matter change as an application moves from local setup to authentication, background work and production operations. At Redberry, our Laravel work spans custom applications, CMS platforms and ongoing product development. This guide brings the questions from our five-part FAQ series into one reference.
The examples follow current Laravel conventions. For an existing application, check its installed version before applying configuration or upgrade instructions. The documentation linked in each section provides the version-specific detail.
How do you check the Laravel version?
Run php artisan --version from the application's root directory to see the installed Laravel framework version.
php artisan --version
composer show laravel/framework
The Composer command also shows the installed package version and dependency information. Check the installed version rather than relying only on the version constraint in composer.json. Laravel's release notes explain version support and platform requirements.
How do you upgrade a Laravel project?
Upgrade a Laravel project by following the official guide for each target major version and checking the application's PHP and package compatibility.
Start with a working test suite and a backup and recovery plan. Review framework changes, Composer dependencies, custom integrations and deployment requirements. Apply the changes in a development branch, test them in a representative staging environment and plan the production rollout separately.
Do not treat a successful Composer update as proof that the application works. Test authentication, scheduled tasks, queues, payment or other external integrations, and the workflows your users depend on. Use the official upgrade guide for the version you are moving to.
How do you run a Laravel project locally, including with XAMPP?
A Laravel project needs a compatible PHP runtime, Composer dependencies, application configuration and any services it uses, such as a database or queue backend.
For an existing project, follow its README and environment setup instructions first. A typical local setup includes:
- Install the PHP version and extensions required by the project.
- Run
composer installto install the locked dependencies. - Create a local
.envfrom the project's example configuration and set the database connection. - Generate an application key for a new local environment with
php artisan key:generate. - Run the project's migrations against the intended local database.
- Install and build frontend assets when the project requires them.
XAMPP can supply Apache and a local database, but check that its PHP version meets the application's requirements. If Apache serves the application, point the virtual host's document root at Laravel's public directory. Exposing the project root risks exposing files that should never be public.
For a simple local development server, run php artisan serve from the project directory. It uses PHP's development server rather than Apache. Laravel Herd and Sail are other local-development options. See the installation documentation for the current setup paths. Do not replace an existing production application's encryption key as part of a routine setup or deployment.
What is a namespace in Laravel?
A namespace groups PHP classes, functions and constants under a qualified name, helping avoid naming collisions and organise code.
Laravel uses PHP namespaces throughout the application. A controller might be named App\Http\Controllers\OrderController, while a model is named App\Models\Order. A use statement lets a file refer to a class without repeating its full namespace.
Namespaces are a PHP feature, not a Laravel-specific mechanism. See the PHP namespace documentation.
How many controllers should a Laravel application have?
A Laravel application should have enough controllers to keep request handling cohesive and understandable; there is no fixed controller count.
Group related HTTP actions around a resource or use case. An orders controller can handle standard order operations, while a separate invokable controller can handle a distinct action such as approving an order.
Split a controller when its actions have different responsibilities or dependencies. Avoid creating a controller for every method simply to make files smaller. Laravel supports both resource and single-action controllers.
What does Route::get() do?
Route::get() registers a route that responds to HTTP GET requests at a specified URL.
use Illuminate\Support\Facades\Route;
Route::get('/status', function () {
return ['status' => 'ok'];
});
GET routes should retrieve information rather than change application state. Use the appropriate HTTP methods, validation and authorisation for operations that create, update or delete data. See Laravel's routing documentation.
Why do you pass data to a Laravel view?
Passing data to a view gives the presentation layer the values it needs to render a response without making the template responsible for fetching them.
return view('orders.show', ['order' => $order]);
The Blade view can then access $order. Keep database access and business decisions outside the template so they can be tested and reused. Laravel documents the available approaches in its views guide.
What is the service container, and how do facades use it?
Laravel's service container resolves objects and their dependencies; facades provide a static-looking interface to services resolved through that container.
When a controller needs a concrete service, Laravel can often inject it automatically. When code depends on an interface, a container binding tells Laravel which implementation to use.
A facade such as Cache forwards calls to its underlying service. The syntax looks static, but the facade resolves an object through the container. Read the container and facade documentation before introducing custom bindings or facades.
What is a service provider?
A service provider registers application services and performs bootstrapping work when Laravel starts.
Use a provider's register() method for container bindings and its boot() method for work that depends on registered services. Generate one with php artisan make:provider ExampleServiceProvider. Registration conventions differ between Laravel generations, so use the provider documentation for your application version.
How do you create a custom Artisan command?
Create an Artisan command with php artisan make:command, then define its command signature and implement its behaviour.
php artisan make:command ImportOrders
The generated class belongs in app/Console/Commands. Define arguments and options in the command signature, and keep reusable business behaviour in application services rather than duplicating it inside commands.
For commands that change data, consider validation, useful output, error exit codes and whether rerunning the command is safe. See the Artisan documentation.
How does Laravel task scheduling work?
Laravel's scheduler defines when commands or jobs should run; the hosting environment must still invoke the scheduler.
Modern Laravel applications commonly define schedules in routes/console.php. A production server can invoke php artisan schedule:run every minute, or a managed platform can provide the scheduler process. Use php artisan schedule:list to inspect registered schedules.
A scheduled job and a queue worker solve different problems. The scheduler dispatches work at the right time; a worker executes queued work. Consider overlapping executions, time zones and single-server execution where relevant. See the scheduling documentation.
How do you check whether a Laravel queue is working?
Check queue health by confirming that the correct worker is running and that a test job reaches completion on the intended connection and queue.
A running PHP process alone does not prove that jobs are being processed. Check the process manager or hosting platform, queue backlog, failed jobs and application logs. Confirm that the worker listens to the same connection and queue that the application uses when dispatching jobs.
php artisan queue:failed lists recorded failed jobs. For Redis-backed queues, Laravel Horizon provides a dashboard and worker management. A production worker should run under an appropriate process manager or managed-platform service. Follow the queue documentation for deployment and worker-restart behaviour.
How do you clear Laravel logs safely?
Manage Laravel logs through the configured logging channel and retention policy rather than assuming every application writes to a single local file.
Inspect config/logging.php and the active channel configuration first. Logs may go to a file, standard error or an external service. A local storage/logs/laravel.log file is only one possible destination.
For disposable local-development logs, stop or account for active writers before removing or truncating the intended file. In production, preserve incident evidence and follow the application's retention requirements. Do not delete every log file as a routine troubleshooting step.
The daily channel supports a configurable retention period. Laravel does not require a third-party package merely to manage file retention, and the framework does not provide a universal built-in log:clear command. See the logging documentation.
What are seeders in Laravel?
Seeders populate a database with initial or sample records using application code.
They are useful for reference data, local setup and test environments. Factories generate model data and can be called from seeders. A seeder can be run with php artisan db:seed, optionally selecting a class with --class.
Keep realistic development fixtures separate from production reference data. Check the target environment and database before running a seeder, and design repeatable seeders where the workflow requires reruns. See the database seeding documentation.
How do you save an Eloquent model?
Set an Eloquent model's attributes and call save() to insert or update its database record.
use App\Models\Order;
$order = new Order();
$order->reference = 'ORDER-1001';
$order->save();
Calling save() on a retrieved model updates that record. Validate incoming data, authorise the operation and use a database transaction when several related writes must succeed together. The Eloquent documentation covers inserts, updates and model events.
Why do Laravel models use fillable attributes?
Fillable attributes define which model fields may be assigned through Eloquent's mass-assignment methods, such as create() and fill().
For example, a user profile form may accept a name while excluding an administrator flag. Defining allowed attributes helps prevent unintended fields from being mass-assigned.
Mass-assignment protection does not replace request validation or authorisation, and it does not prevent direct attribute assignment. Pass only the intended validated fields to the model. See mass assignment in Eloquent.
How do you use Eloquent whereIn()?
whereIn() filters records by checking whether a column matches one of the values in a supplied set.
use App\Models\User;
$users = User::whereIn('id', [1, 2, 3])->get();
Use an authorised, validated set of values when the input comes from a request. For very large sets, consider a subquery or another query strategy rather than building an oversized list in memory. See the query builder documentation.
How do Eloquent relationships work?
Eloquent relationships express how models relate, allowing application code to query associated records through model methods.
Use hasOne() and belongsTo() for a one-to-one relationship, hasMany() and belongsTo() for one-to-many, and belongsToMany() for many-to-many relationships through an intermediate table.
For example, an order can belong to a customer while a customer has many orders. Load the relationships needed by a list using eager loading to avoid issuing an extra query for each row. The relationship documentation explains keys, intermediate tables and eager loading.
Is Laravel authentication secure, and how do you implement it?
Laravel provides established authentication tools, but application security also depends on configuration, authorisation, updates and deployment practices.
For a new application, an official starter kit can provide registration, login and related account flows. Laravel Fortify supplies backend authentication functionality when you need to build the interface separately.
Choose a flow that matches the client: a browser session, a first-party SPA, a mobile app or a third-party integration. Do not build password hashing or token generation from scratch. Add access controls, rate limiting and account recovery appropriate to the product. Start with Laravel's authentication guide.
How does Laravel protect against CSRF?
Laravel's CSRF protection checks eligible browser requests to help prevent another site from submitting actions using a visitor's authenticated session.
For Blade forms, include the @csrf directive. JavaScript clients must send the expected CSRF credentials according to the chosen authentication flow. Browser session authentication and stateless API-token authentication have different requirements.
Keep protection enabled for session-based state-changing routes, and do not broadly exempt routes just to suppress a token error. See the version-specific CSRF documentation.
What is Laravel Sanctum, and when do you need an access token?
Laravel Sanctum supports first-party SPA authentication using sessions and cookies, as well as API authentication using personal access tokens.
A first-party SPA does not need to store a personal access token merely because it calls a Laravel API. Sanctum's stateful SPA flow uses Laravel's session authentication and CSRF protection.
Personal access tokens suit clients such as mobile applications or external integrations. Limit token abilities, protect stored credentials and define revocation and expiry behaviour. Use Laravel Passport when the application needs a full OAuth2 authorisation server. See the Sanctum documentation for the correct flow.
What is the difference between a gate and a policy?
Gates and policies both authorise actions; policies group rules around a model or resource, while gates suit abilities that do not need that grouping.
An order policy can define who may view, update or cancel an order. A gate can control an application-wide ability such as viewing an operations dashboard.
Authentication identifies the user. Authorisation determines what that user may do. Enforce access on the server even when the interface hides unavailable actions. See Laravel's authorisation documentation.
Is Laravel a good choice for API development?
Laravel is a suitable API foundation when its PHP ecosystem, database tools and application conventions fit the product and the team.
It provides routing, validation, authentication options, database access, queues and testing tools. A dependable API still requires an explicit contract: who can call it, what each response means, how errors are reported and how breaking changes are managed.
Choose the framework around the application's constraints and the team's ability to operate it. See API resources for transforming model data into controlled response structures.
Can Laravel integrate with an external REST API?
Laravel can call external REST APIs through its HTTP client, with support for authentication headers, timeouts, retries and testing fakes.
Set explicit timeouts, handle unsuccessful responses and protect API credentials. Retry only when repeating the operation is safe; a timed-out payment or order request may already have succeeded at the remote system.
For longer-running integrations, consider queued work, idempotency and reconciliation. See the HTTP client documentation.
How do you install a third-party Laravel package?
Install PHP packages with Composer after checking their compatibility, maintenance status, licence and operational requirements.
Use the package's documented Composer command, then follow its installation instructions for any migrations, configuration or assets. Commit the resulting dependency changes and test the application.
Composer can report known dependency advisories through composer audit, but a clean result is not a complete security review. See the Composer require documentation.
What is a Laravel starter kit?
A Laravel starter kit is an application starting point that supplies common authentication flows and a frontend foundation.
The official kits offer different frontend approaches, including React, Vue and Livewire. Choose the kit that matches the team's skills and the product's interaction needs. A kit accelerates setup; it does not supply your domain model, access rules or production operating process. Check the current starter kits before starting a new project.
Can you use Laravel with React or Vue?
Laravel can work with React or Vue through Inertia or as the backend for a separately deployed frontend.
Inertia lets a Laravel application render React or Vue pages while keeping server-side routing and controllers. A separate frontend can communicate with Laravel through an API, with authentication and deployment boundaries designed accordingly.
Choose the boundary you need rather than introducing a separate API by default. Laravel's frontend documentation explains the main options.
Can Laravel use WordPress as a CMS?
Laravel can use WordPress as a content backend by retrieving content through WordPress's REST API.
That separation can preserve a familiar editing interface while Laravel owns application behaviour. It also leaves two systems to maintain. Plan previews, media delivery, authentication, caching and content invalidation before choosing a headless setup.
Use the WordPress REST API documentation to confirm which content and authentication capabilities your integration needs.
Which Laravel CMS should you choose?
Choose a Laravel CMS by testing the actual editorial workflows, content structure and custom behaviour the organisation needs.
A content platform such as Statamic or October CMS may suit a content-led site. A custom admin built with Filament can suit application-specific workflows, but Filament is an admin-panel framework rather than a complete CMS out of the box.
Test a real publishing task: create a page, preview it, obtain approval, publish it and correct it. Then evaluate permissions, localisation, redirects and maintenance. Redberry's Filament Page Builder plugin is one public example of extending an admin panel for page editing.
Which Laravel ecommerce package should you use?
The right ecommerce package depends on catalogue rules, checkout requirements, integrations and the amount of application behaviour you need to own.
Lunar is a headless Laravel ecommerce option. Other projects, including Bagisto, Aimeos and Vanilo, take different approaches. Compare the current supported releases, extension points and licensing rather than declaring one universally best.
Prototype the difficult part first: pricing rules, inventory synchronisation, tax, subscriptions or a non-standard checkout. Review our Laravel ecommerce development approach if the store must integrate with a wider business system.
When should you choose Laravel Forge or Laravel Cloud?
Choose Forge when you need server management with infrastructure control; evaluate Laravel Cloud when you want a managed application platform.
Forge handles tasks such as provisioning, deployment and certificates, while the operating responsibilities depend on the infrastructure and services you choose. Laravel Cloud provides a managed deployment environment with application resources.
Compare the responsibilities that remain with your team: operating-system maintenance, database operations, backups, networking, monitoring and incident response. Include those responsibilities in the cost comparison.
Is Laravel Cloud suitable for a large application?
Laravel Cloud can be evaluated for large Laravel applications, but suitability depends on the workload and its operational requirements.
Assess web traffic, database behaviour, queue throughput, storage, regions, networking and recovery requirements. Load-test a representative workload and check the current platform limits and commercial terms.
Do not infer regulatory suitability from the hosting choice alone. The application's controls and the client's requirements still need their own review. Use the current Laravel Cloud product information and documentation rather than old roadmap promises or blanket scalability claims.
How should you decide which Laravel tool belongs in your application?
Evaluate a Laravel tool against the work it removes, the operating responsibility it introduces and the future changes your team must support.
That decision is more useful than choosing the longest feature list. For each candidate, identify one real workflow, one failure scenario and one likely change. Test all three before committing the application to it.
If you need help with an existing codebase or a new platform, explore our Laravel development services or tell us about your application.






