PHP powers a significant share of the world's websites and remains widely used in Indian web development agencies, ecommerce companies, and content platforms. Laravel, the dominant PHP framework, has modernised PHP development with an Eloquent ORM, elegant routing, and a strong community. This guide covers PHP and Laravel interview questions for Indian companies in 2026.
PHP/Laravel developer salary in India 2026
PHP/Laravel developer salary India (2024-25):
Junior PHP/Laravel developer (0-2 years): 3-9 LPA at agencies and startups; 2-5 LPA at IT services. Mid-level Laravel developer (3-5 years): 8-22 LPA at product companies. Senior Laravel developer/architect (5-8 years): 18-45 LPA.
PHP vs other languages salary comparison: PHP developers in India earn 20-30% less than equivalent Python or Java engineers at product companies. However, PHP/Laravel remains extremely widespread, and senior Laravel architects at agencies or ecommerce companies can earn 20-40 LPA.
Where PHP is used in India:
- Web development agencies (the largest employer of PHP developers in India)
- Ecommerce companies (many Indian ecommerce stores use WooCommerce or custom Laravel)
- News and publishing companies (many Indian news portals use WordPress which is PHP)
- Legacy systems at older product companies migrating gradually
Is PHP a good career choice in India in 2026? PHP remains viable for web development agency work and ecommerce. However, if you are targeting product companies, salary ceilings are lower than Python, Java, or JavaScript. Consider learning Python or JavaScript as a second language to expand your options.
PHP fundamentals: OOP, magic methods, and PHP 8 features
PHP fundamentals interview questions:
1. PHP magic methods: - _construct(): called automatically when an object is created - destruct(): called when an object is garbage collected - get(name) and set(name, value): called when reading/writing inaccessible or undefined properties (used in ActiveRecord patterns) - toString(): called when an object is cast to a string (echo $object) - call(name, args): called when an inaccessible or undefined method is invoked - _invoke(): called when the object is used as a function
2. PHP OOP: Interfaces: define a contract that classes must implement (interface Serializable { public function serialize(): string; }). Abstract classes: partial implementations that cannot be instantiated directly. Traits: reusable code that can be mixed into classes (horizontal code reuse without multiple inheritance). Static methods and properties: belong to the class, not to instances.
3. PHP 8 features (commonly asked): - Named arguments: sendEmail(to: 'user@example.com', subject: 'Hello'); pass arguments by name, in any order - Match expression: cleaner than switch; strict type comparison; must be exhaustive - Nullsafe operator (?.): $country = $user?->getAddress()?->country; stops and returns null if any part is null (no null pointer exception) - Constructor property promotion: class User { public function __construct(public string $name, public string $email) {} } auto-creates and assigns properties - Union types: public function handle(int|string $id): void - Fibers (PHP 8.1): cooperative multitasking (the foundation for async PHP frameworks like ReactPHP and Amp)
Laravel: routing, middleware, and Eloquent ORM
Laravel framework interview questions:
1. Laravel routing: web.php: routes for browser requests (with session, CSRF protection). api.php: routes for stateless API requests (no session; with rate limiting). Route model binding: Route::get('/posts/{post}', function (Post $post) {}); Laravel automatically fetches the Post with the given ID and throws 404 if not found.
2. Laravel middleware: Middleware is code that runs before or after a request enters the application. Common built-in middleware: Authenticate (check if user is logged in), ThrottleRequests (rate limiting), VerifyCsrfToken (CSRF protection). Custom middleware example: logging all API requests with their response times. Apply middleware: to individual routes (Route::get('...')->middleware('auth')), to route groups, or globally.
3. Eloquent ORM: Eloquent maps database tables to PHP classes (Model). The model class name (User) maps to the table name (users by convention). Key features: - Query builder: User::where('active', 1)->orderBy('name')->paginate(20) - Relationships: hasOne, hasMany, belongsTo, belongsToMany, hasManyThrough - Eager loading: User::with('posts.comments')->get() loads users with their posts and each post's comments in 3 queries (not N+1) - Accessors and mutators: define getFullNameAttribute() to compute a property dynamically - Soft deletes: adds deletedat column; delete() sets deletedat instead of actually deleting; SoftDeletes trait includes withTrashed() and onlyTrashed() scopes
4. Laravel Queues and Jobs: Queues allow deferring time-consuming tasks (sending emails, processing images, third-party API calls) so the HTTP response is not delayed. dispatch(new SendWelcomeEmail($user)); the job runs asynchronously via Laravel Horizon (Redis-backed queue worker supervisor). Very common in Indian ecommerce and SaaS companies for order processing and notification workflows.
Practise PHP and Laravel interview questions with HireStepX's AI voice interviewer. Get scored feedback on your explanations of MVC, Eloquent, and Laravel security concepts. First 2 sessions free.
Practice freeLaravel REST API, testing, and security
Laravel REST API and security:
1. Building REST APIs with Laravel: Route::apiResource('posts', PostController::class): generates all 7 RESTful routes (index, store, show, update, destroy, etc.). API Resources: transform Eloquent models to JSON responses; control which fields are exposed (do not expose password hashes or sensitive fields). Request validation: FormRequest classes encapsulate validation rules; fail with a 422 response and structured error messages automatically.
2. Authentication with Laravel Sanctum: Laravel Sanctum: API token authentication and SPA authentication for first-party apps. For mobile apps: issue a plain-text API token on login; include in Authorization: Bearer <token> header on subsequent requests. For SPAs (same-origin React/Vue): use cookie-based session authentication (more secure than bearer tokens for browser clients).
3. Security in Laravel: SQL injection: Eloquent and the query builder use parameterised queries by default; never concatenate raw user input into queries. XSS: Blade templates escape output by default ({{ $name }} is escaped; {!! $html !!} is unescaped). Use {!! !!} only for trusted content. CSRF: VerifyCsrfToken middleware is active for all web routes by default; include @csrf in all HTML forms. Mass assignment: use $fillable (whitelist) or $guarded (blacklist) on every Eloquent model; never set $fillable = ['*'] or $guarded = [].
4. Laravel testing: PHPUnit is built in. Feature tests: test HTTP endpoints end-to-end (make a request, assert the response status and JSON structure). Unit tests: test individual classes and methods in isolation. Database testing: use RefreshDatabase or DatabaseTransactions traits to reset the database between tests. Factories: Eloquent model factories generate fake test data (User::factory()->count(50)->create()).
Frequently asked questions
Explore more