1. Go to this page and download the library: Download miguelex/php-template 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/ */
miguelex / php-template example snippets
// src/Models/Post.php
final class Post extends ActiveRecord {
protected static string $table = 'posts';
protected static array $columns = ['id', 'title', 'body'];
public string $title = '';
public string $body = '';
}
// Uso directo
$post = Post::find(1);
$posts = Post::all();
$post->title = 'Nuevo título';
$post->save();
// src/Repositories/PostRepository.php
final class PostRepository extends BaseRepository {
protected string $table = 'posts';
public function findPublished(): array {
return $this->findWhere(['published' => 1], 'created_at DESC');
}
protected function hydrate(array $row): Post { ... }
protected function extract(object $entity): array { ... }
}
// Uso con inyección
$repo = new PostRepository(Database::connect());
$posts = $repo->paginate(page: 1, perPage: 10);
bash
brew install php composer node@20
bash
git clone https://github.com/miguelex/php-template.git
cd php-template
./init-project.sh
bash
# Gulp + PHP server en una sola terminal
npm run dev
# Vite + PHP server en una sola terminal
npm run dev:vite
# Solo servidor PHP (backend-only)
npm run php