PHP:
Starting a new project

How to:

Kickstart your project by choosing a structure. Composer’s your friend here. Run this:

composer init

Then, create your index.php. It’s your entry point:

<?php
// index.php
echo "Welcome to my new PHP project!";

Test it on your local server. You should see:

Welcome to my new PHP project!

Deep Dive

Back in the day, PHP projects began with simple scripts. No package management, no frameworks, just pure PHP files. Now, we’ve got Composer, a tool to manage dependencies, autoload classes, and set up autoloading standards like PSR-4. It’s standard practice for modern PHP projects.

You could roll old-school, no Composer, no autoloaders. But why ignore the convenience and standards widely adopted?

Use frameworks like Laravel or Symfony for complex apps. They provide structure and tools, speeding up development. For smaller projects, micro-frameworks like Slim might be enough.

Implementation wise, consider environment variables for config, adopt PSR standards for coding style and structure, and don’t skip on a version control system like Git.

See Also