Gwack is a modern PHP framework designed for full-stack development with seamless Vue.js integration. Built with developer experience in mind, it offers file-based routing, powerful dependency injection, and fast development workflow.
- File-Based Routing: Zero configuration routing - just create PHP files in your
server/directory - Vue.js Integration: Native Vue.js support with hot module reloading
- High Performance: Optimized router with static route lookup and intelligent regex grouping
- PSR Compliant: Built on Symfony components with PSR standards compliance
- Dependency Injection: Container system with automatic resolution and caching
- Developer Experience: CLI tools for project scaffolding, development server, and production builds
- API-First Design: RESTful API server with built-in serialization and validation
# Install the CLI globally
npm install -g @gwack/cli
# Create a new project
gwack create my-app
# Navigate to your project
cd my-app
# Install PHP dependencies
composer install
# Start development server
gwack dev# Install via Composer
composer require gwack/core
# Install frontend tooling
npm install @gwack/climy-app/
βββ pages/ # Vue.js pages (frontend)
β βββ index.vue # Home page
β βββ about.vue # About page
βββ server/ # PHP API routes (backend)
β βββ posts/
β β βββ index.php # GET/POST /api/posts
β βββ users/
β βββ [id].php # GET/POST /api/users/{id}
βββ assets/ # Static assets
βββ gwack.config.js # Framework configuration
βββ composer.json # PHP dependencies
βββ package.json # Node.js dependencies
βββ index.html # Entry point
Create API endpoints by adding PHP files to the server/ directory:
<?php
// server/posts/index.php
function getPosts() {
return [
['id' => 1, 'title' => 'Hello World'],
['id' => 2, 'title' => 'Getting Started']
];
}
// Return a JSON response
return fn() => json(getPosts());Available at: GET /api/posts
Use bracket notation for dynamic parameters:
<?php
// server/posts/[id].php
return function() {
$request = request();
$id = $request->get('id');
return json(['id' => $id, 'title' => "Post #{$id}"]);
};Available at: GET /api/posts/123
Create Vue.js pages in the pages/ directory:
<!-- pages/index.vue -->
<template>
<div>
<h1>Welcome to Gwack</h1>
<div v-for="post in posts" :key="post.id">
<h2>{{ post.title }}</h2>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const posts = ref([])
onMounted(async () => {
const response = await fetch('/api/posts')
posts.value = await response.json()
})
</script># Start development server with hot reloading
gwack dev
# Build for production
gwack build
# Create new project
gwack create <project-name>
# Development server options
gwack dev --port 3000 --php-port 8080 --host localhostexport default {
php: {
port: 8080,
},
frontend: {
port: 3000,
},
build: {
target: 'es2020',
},
}<?php
// index.php
use Gwack\Core\Application;
require_once 'vendor/autoload.php';
$app = new Application(__DIR__);
$app->configure([
'env' => 'development',
'debug' => true,
'api_prefix' => '/api'
]);
$app->boot()->run();- Application: Main application class that bootstraps the framework
- Router: High-performance HTTP router with route compilation and caching
- Container: Dependency injection container with automatic resolution
- ApiServer: RESTful API server with middleware support
- FileBasedRouter: Automatic route discovery from filesystem
The framework provides pre-registered functions available in all route handlers:
// Available functions in route handlers
json($data, $status = 200) // Create JSON response
request() // Get current request
context() // Get application context
config($key) // Get configuration value
logger() // Get logger instance
session() // Get session manager
validate($rules) // Validate request data// Add middleware to API server
$app->getApiServer()->addMiddleware(new CorsMiddleware());
$app->getApiServer()->addMiddleware(new AuthMiddleware());// Register routes programmatically
$app->addRoute('GET', '/custom', function() {
return json(['message' => 'Custom route']);
});// Bind custom services
$app->getContainer()->bind('myService', function() {
return new MyService();
});
// Access in route handlers
return function() {
$service = container()->get('myService');
return json($service->getData());
};- PHP: 8.3 or higher
- Node.js: 18.0 or higher
- Composer: For PHP dependency management
- npm/yarn: For frontend dependencies
# Run PHP tests
composer test
# Run with coverage
./vendor/bin/phpunit --coverage-html coverageMIT License. See LICENSE for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with β€οΈ by the Gwack Framework Team