Composer
Composer is PHP's dependency manager — the tool that installs libraries and wires up autoloading.
composer init # create composer.json
composer require guzzlehttp/guzzle
composer install # install from composer.lock
composer update # update to newer allowed versions
composer dump-autoload # rebuild the autoloaderThen one line loads everything:
<?php
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$res = $client->get('https://api.example.com/books');
echo $res->getBody();What to commit
- Commit
composer.jsonandcomposer.lock. - Ignore
vendor/— it's rebuilt withcomposer install.
The lock file pins exact versions so every machine and server installs the same code.
Where to go next
You now have the core language: types, control flow, functions, arrays, OOP, error handling, and safe database access. Sensible next steps:
A framework. Laravel is the most popular choice in Nepal and has excellent documentation; Symfony is more explicit and modular. Both give you routing, templating, migrations, validation, and authentication so you stop rewriting them.
PSR standards. PSR-1/PSR-12 (coding style) and PSR-4 (autoloading)
are what the whole ecosystem follows. Run php-cs-fixer or phpcs to
apply them automatically.
Testing. PHPUnit or Pest. Even a handful of tests around your pricing and validation logic pays for itself quickly.
Static analysis. PHPStan or Psalm read your code and find bugs without running it. Start at a low level and raise it gradually — it is the fastest way to improve an existing codebase.
Modern PHP. If you learned PHP years ago, revisit it: typed
properties, constructor promotion, enums, match, named arguments,
readonly, and fibers have changed the language substantially.
A short checklist for every project
declare(strict_types=1);at the top of every file.- Prepared statements for every query.
htmlspecialchars()on every output.password_hash()for every password.- Errors logged, never displayed in production.
- Secrets in environment variables, not in git.
Get those six right and you are ahead of a large share of PHP code running in production today.