baseapi / baseapi-template
Project template for BaseAPI - a tiny, KISS-first PHP 8.4 framework
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Type:project
pkg:composer/baseapi/baseapi-template
Requires
- php: ^8.4
- baseapi/baseapi: ~1.2.2
Requires (Dev)
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.0
- rector/rector: ^1.2
- dev-main
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.0
- v0.7.10
- v0.7.8
- v0.7.5
- v0.7.3
- v0.7.0
- v0.6.0
- v0.5.7
- v0.5.6
- v0.5.5
- v0.5.4
- v0.5.1
- v0.5.0
- v0.4.11
- v0.4.10
- v0.4.8
- v0.4.7
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3.1
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.2.0
- v0.1.12
- v0.1.11
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
This package is auto-updated.
Last update: 2025-10-08 10:53:11 UTC
README
This is the "empty" template project using baseapi. Creating a new project with baseapi will use this as a starter template.
Quick Start
Create a new baseapi project "my-api" using Composer:
composer create-project baseapi/baseapi-template my-api
cd my-api
Copy the environment example file and start the server
cp .env.example .env php mason serve
Your API will be available at http://localhost:7879
.
You can change host and port in the .env file.
Console commands are run using:
php mason
Git Hooks
This template includes pre-commit hooks that automatically check code quality:
- PHP Syntax Check - Validates all staged PHP files
- PHPStan Analysis - Static code analysis (if available)
- Tests - Runs PHPUnit tests when core files change
- Code Quality - Prevents debugging functions in commits
- File Size Warnings - Alerts for large files
Setup
Hooks are automatically installed when creating a new project. To reinstall manually:
composer setup-hooks
Bypass Hook (Not Recommended)
git commit --no-verify -m "Skip pre-commit checks"
See .githooks/README.md
for detailed documentation.
Dependency Injection Example
This template demonstrates BaseAPI's dependency injection system:
EmailService Example
The SignupController
shows how to inject services:
class SignupController extends Controller { private EmailService $emailService; public function __construct(EmailService $emailService) { $this->emailService = $emailService; } public function post(): JsonResponse { // ... user creation logic ... // Use injected service $this->emailService->sendWelcome($user->email, $user->name); return JsonResponse::ok($user->jsonSerialize()); } }
Service Provider
Services are registered in app/Providers/AppServiceProvider.php
:
public function register(ContainerInterface $container): void { $container->singleton(EmailService::class); $container->singleton(UserProvider::class, SimpleUserProvider::class); }
Configuration
Providers are registered in config/app.php
:
'providers' => [ \App\Providers\AppServiceProvider::class, ],
Documentation
For full framework documentation, features, and usage examples, see:
- BaseAPI Repository - Complete documentation
BaseAPI - The tiny, KISS-first PHP 8.4 framework that gets out of your way.