PHPStarter/README.md

112 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PHPStarter
A minimal, modern PHP project template that provides a clean foundation for building small to medium web applications.
## Features
- PSR4 autoloading via Composer
- Environment configuration using [`vlucas/phpdotenv`](https://github.com/vlucas/phpdotenv)
- Strict typing enabled across the project
- Simple and extensible database connection helper
- Readytouse [PHPUnit](https://phpunit.de/) testing setup
- [PHPCSFixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) configuration for consistent code style
- Clean `public/` entry point for web requests
- Fully compatible with the [PHPStarter CLI](https://gitea.ramoncaballero.dev/mon/phpstarter-cli.git)
## Requirements
- PHP 8.2+
- Composer
- Apache (or PHP's builtin server)
- MariaDB
## Installation
It is recommended to use [PHPStarter CLI](https://gitea.ramoncaballero.dev/mon/phpstarter-cli.git), as it automates the entire setup process and requires almost no manual configuration.
However, you can also install PHPStarter manually by following the steps below.
Clone the repository:
```bash
cd /var/www/sites/
git clone https://gitea.ramoncaballero.dev/mon/PHPStarter.git <myproject>
cd <myproject>
```
Install dependencies:
```bash
composer install
```
Copy the environment file:
```bash
sudo cp config/PHPStarter.env.example config/PHPStarter.env
```
Edit your environment variables as needed.
## Directory Structure
```bash
PHPStarter/
bin/ → Executable scripts or CLI utilities
config/ → Environment files
docs/ → Project documentation, guides, and reference material
public/ → Web root; front controller (`index.php`) and public assets (css, js, icons, ...)
src/ → Application source code (PSR4 autoloaded)
templates/ → Reusable HTML/PHP templates or view files
tests/ → PHPUnit test suites and testing utilities
translations/ → Localization files, language packs, or message catalogs
composer.json → Composer package definition and autoload configuration
composer.lock → Locked dependency versions for reproducible installs
phpunit.xml → PHPUnit configuration file
.php-cs-fixer.dist.php → Code style rules for PHP-CS-Fixer
```
## Running the Project
Using PHP's builtin server:
```bash
php -S localhost:8000 -t public
```
Or configure Apache manually.
If using the [PHPStarter CLI](https://gitea.ramoncaballero.dev/mon/phpstarter-cli.git), the virtual host is created automatically.
## Customization
You can safely modify:
- Namespace (default: `PHPStarter`)
- Directory structure
- Database logic
- Views/templates
The template is intentionally minimal to encourage flexibility.
## Testing
Run PHPUnit:
```bash
./vendor/bin/phpunit
```
## Code Style
Run PHP-CS-Fixer:
```bash
./vendor/bin/php-cs-fixer fix
```
## License
This project is provided as a template and may be used freely.