Laravel

Composer & Autoloading

Composer basics, composer.json, autoloading PSR-4, dependency management, semantic versioning, scripts, security audit

18 คำถามสัมภาษณ์·
Junior
1

What is Composer in the PHP ecosystem?

คำตอบ

Composer is the standard dependency manager for PHP, allowing developers to declare and install libraries that a project depends on. It automatically manages compatible versions and downloads packages from Packagist. Unlike PEAR (legacy manager), Composer installs dependencies per project rather than globally.

2

Which file contains the list of dependencies for a PHP project managed by Composer?

คำตอบ

The composer.json file is the project manifest that declares all dependencies, custom scripts, autoloading configuration, and project metadata. This file is versioned in Git and edited manually. The composer.lock is automatically generated and should never be manually edited.

3

Which Composer command installs project dependencies without updating composer.lock?

คำตอบ

The composer install command reads the composer.lock file (or composer.json if .lock is missing) and installs exactly the specified versions, ensuring identical installations across all environments. In production or when cloning a project, always use install to reproduce the exact environment. The update command upgrades versions and modifies composer.lock.

4

What is the difference between require and require-dev in composer.json?

5

What is the role of the composer.lock file?

+15 คำถามสัมภาษณ์

เชี่ยวชาญ Laravel สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี