1. Go to this page and download the library: Download amanprojects/phpstart library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amanprojects / phpstart example snippets
// Simple read
$name = env('APP_NAME');
// With fallback default
$host = env('DB_HOST', 'localhost');
$port = env('DB_PORT', '3306');
// Boolean check
$debug = env('APP_DEBUG', 'false') === 'true';
// Inside a class
class Database
{
public function connect(): PDO
{
$dsn = sprintf(
'%s:host=%s;port=%s;dbname=%s;charset=%s',
env('DB_CONNECTION', 'mysql'),
env('DB_HOST', '127.0.0.1'),
env('DB_PORT', '3306'),
env('DB_DATABASE', ''),
env('DB_CHARSET', 'utf8mb4')
);
return new PDO($dsn, env('DB_USERNAME'), env('DB_PASSWORD'));
}
}
bash
php --version
# PHP 8.1.x or higher
bash
# Windows — add PHP folder to system Path
# e.g. C:\xampp\php or C:\php
# Linux/macOS — usually auto-added, verify with:
which php