A skeleton for modern PHP development, providing a clean structure and essential tooling.
- PSR-4 autoloading
- Pest for testing
- Laravel Pint for code formatting
- PHPStan for static analysis
- Rector for code refactorin
- Compatible with php 8.2 , 8.3 and 8.4
composer lint
composer test:unit
composer test:types
composer test:lint
composer test
src/ # Main source code
tests/ # Unit and feature tests
<?php
declare(strict_types=1);
namespace RoyRakesh\SkeletonPhp\Contracts;
interface GreetingContract
{
public function greet(string $name): string;
}
<?php
declare(strict_types=1);
namespace RoyRakesh\SkeletonPhp\Services;
use RoyRakesh\SkeletonPhp\Contracts\GreetingContract;
class GreetingService implements GreetingContract
{
public function greet(string $name): string
{
return "Hello, $name!";
}
}
<?php
declare(strict_types=1);
namespace RoyRakesh\SkeletonPhp;
use RoyRakesh\SkeletonPhp\Services\GreetingService;
final class Greeting
{
private GreetingService $greetingService;
public function __construct()
{
$this->greetingService = new GreetingService();
}
public function greet(string $name): string
{
return $this->greetingService->greet($name);
}
}
<?php
declare(strict_types=1);
use RoyRakesh\SkeletonPhp\Services\GreetingService;
it('returns a greeting message', function () {
$service = new GreetingService();
expect($service->greet('Rakesh'))->toBe('Hello, Rakesh!');
});
<?php
declare(strict_types=1);
use RoyRakesh\SkeletonPhp\Greeting;
it('greets a user with a name', function () {
$greeting = new Greeting();
$result = $greeting->greet('Rakesh');
expect($result)->toBe('Hello, Rakesh!');
});
it('greets a user with an empty name', function () {
$greeting = new Greeting();
$result = $greeting->greet('');
expect($result)->toBe('Hello, !');
});
This package utilizes the following open-source tools:
- PestPHP - A modern PHP testing framework.
- Laravel Pint - An opinionated PHP code formatter.
- PHPStan - Static analysis tool for PHP.
- Rector - Automated code refactoring tool.
- @nunomaduro - Thanks for insping me to create opensource php projects.
This project is licensed under the MIT License.