From 06ab3456e971df0094d33c1c3fed3a1d0614a6ff Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 26 Jan 2026 17:19:26 +0000 Subject: [PATCH] Initial Core PHP Framework template --- .env.example | 76 +++++++++++++++ .gitattributes | 11 +++ .gitignore | 23 +++++ LICENSE | 16 ++++ README.md | 117 ++++++++++++++++++++++++ app/Http/Controllers/.gitkeep | 0 app/Mod/.gitkeep | 0 app/Models/.gitkeep | 0 app/Providers/AppServiceProvider.php | 24 +++++ artisan | 15 +++ bootstrap/app.php | 23 +++++ bootstrap/cache/.gitignore | 2 + bootstrap/providers.php | 5 + composer.json | 78 ++++++++++++++++ config/core.php | 24 +++++ database/factories/.gitkeep | 0 database/migrations/.gitkeep | 0 database/seeders/DatabaseSeeder.php | 16 ++++ package.json | 16 ++++ phpunit.xml | 33 +++++++ postcss.config.js | 6 ++ public/.htaccess | 21 +++++ public/index.php | 17 ++++ public/robots.txt | 2 + resources/css/app.css | 3 + resources/js/app.js | 1 + resources/js/bootstrap.js | 3 + resources/views/welcome.blade.php | 65 +++++++++++++ routes/api.php | 5 + routes/console.php | 3 + routes/web.php | 7 ++ storage/app/.gitignore | 3 + storage/app/public/.gitignore | 2 + storage/framework/.gitignore | 9 ++ storage/framework/cache/.gitignore | 3 + storage/framework/cache/data/.gitignore | 2 + storage/framework/sessions/.gitignore | 2 + storage/framework/testing/.gitignore | 2 + storage/framework/views/.gitignore | 2 + storage/logs/.gitignore | 2 + tailwind.config.js | 11 +++ tests/Feature/.gitkeep | 0 tests/TestCase.php | 10 ++ tests/Unit/.gitkeep | 0 vite.config.js | 11 +++ 45 files changed, 671 insertions(+) create mode 100644 .env.example create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 app/Http/Controllers/.gitkeep create mode 100644 app/Mod/.gitkeep create mode 100644 app/Models/.gitkeep create mode 100644 app/Providers/AppServiceProvider.php create mode 100755 artisan create mode 100644 bootstrap/app.php create mode 100644 bootstrap/cache/.gitignore create mode 100644 bootstrap/providers.php create mode 100644 composer.json create mode 100644 config/core.php create mode 100644 database/factories/.gitkeep create mode 100644 database/migrations/.gitkeep create mode 100644 database/seeders/DatabaseSeeder.php create mode 100644 package.json create mode 100644 phpunit.xml create mode 100644 postcss.config.js create mode 100644 public/.htaccess create mode 100644 public/index.php create mode 100644 public/robots.txt create mode 100644 resources/css/app.css create mode 100644 resources/js/app.js create mode 100644 resources/js/bootstrap.js create mode 100644 resources/views/welcome.blade.php create mode 100644 routes/api.php create mode 100644 routes/console.php create mode 100644 routes/web.php create mode 100644 storage/app/.gitignore create mode 100644 storage/app/public/.gitignore create mode 100644 storage/framework/.gitignore create mode 100644 storage/framework/cache/.gitignore create mode 100644 storage/framework/cache/data/.gitignore create mode 100644 storage/framework/sessions/.gitignore create mode 100644 storage/framework/testing/.gitignore create mode 100644 storage/framework/views/.gitignore create mode 100644 storage/logs/.gitignore create mode 100644 tailwind.config.js create mode 100644 tests/Feature/.gitkeep create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/.gitkeep create mode 100644 vite.config.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..01b4da4 --- /dev/null +++ b/.env.example @@ -0,0 +1,76 @@ +APP_NAME="Core PHP App" +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_TIMEZONE=UTC +APP_URL=http://localhost + +APP_LOCALE=en_GB +APP_FALLBACK_LOCALE=en_GB +APP_FAKER_LOCALE=en_GB + +APP_MAINTENANCE_DRIVER=file + +BCRYPT_ROUNDS=12 + +LOG_CHANNEL=stack +LOG_STACK=single +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=sqlite +# DB_HOST=127.0.0.1 +# DB_PORT=3306 +# DB_DATABASE=core +# DB_USERNAME=root +# DB_PASSWORD= + +SESSION_DRIVER=database +SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null + +BROADCAST_CONNECTION=log +FILESYSTEM_DISK=local +QUEUE_CONNECTION=database + +CACHE_STORE=database +CACHE_PREFIX= + +MEMCACHED_HOST=127.0.0.1 + +REDIS_CLIENT=phpredis +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=log +MAIL_HOST=127.0.0.1 +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS="hello@example.com" +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +VITE_APP_NAME="${APP_NAME}" + +# Core PHP Framework +CORE_CACHE_DISCOVERY=true + +# CDN Configuration (optional) +CDN_ENABLED=false +CDN_DRIVER=bunny +BUNNYCDN_API_KEY= +BUNNYCDN_STORAGE_ZONE= +BUNNYCDN_PULL_ZONE= + +# Flux Pro (optional) +FLUX_LICENSE_KEY= diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcb21d3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text=auto eol=lf + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore +CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bec2973 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/.phpunit.cache +/node_modules +/public/build +/public/hot +/public/storage +/storage/*.key +/storage/pail +/vendor +.env +.env.backup +.env.production +.phpactor.json +.phpunit.result.cache +Homestead.json +Homestead.yaml +auth.json +npm-debug.log +yarn-error.log +/.fleet +/.idea +/.nova +/.vscode +/.zed diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..126897c --- /dev/null +++ b/LICENSE @@ -0,0 +1,16 @@ +European Union Public Licence +EUPL © European Union 2007, 2016 + +This European Union Public Licence (the 'EUPL') applies to the Work (as defined below) +which is provided under the terms of this Licence. Any use of the Work, other than as +authorised under this Licence is prohibited (to the extent such use is covered by a right +of the copyright holder of the Work). + +The Work is provided under the terms of this Licence when the Licensor (as defined below) +has placed the following notice immediately following the copyright notice for the Work: + +Licensed under the EUPL + +or has expressed by any other means his willingness to license under the EUPL. + +For the full EUPL text, see: https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 diff --git a/README.md b/README.md new file mode 100644 index 0000000..0d81dee --- /dev/null +++ b/README.md @@ -0,0 +1,117 @@ +# Core PHP Framework Project + +A modular monolith Laravel application built with Core PHP Framework. + +## Features + +- **Core Framework** - Event-driven module system with lazy loading +- **Admin Panel** - Livewire-powered admin interface with Flux UI +- **REST API** - Scoped API keys, rate limiting, webhooks, OpenAPI docs +- **MCP Tools** - Model Context Protocol for AI agent integration + +## Requirements + +- PHP 8.2+ +- Composer 2.x +- SQLite (default) or MySQL/PostgreSQL +- Node.js 18+ (for frontend assets) + +## Installation + +```bash +# Clone or create from template +git clone https://github.com/host-uk/core-template.git my-project +cd my-project + +# Install dependencies +composer install +npm install + +# Configure environment +cp .env.example .env +php artisan key:generate + +# Set up database +touch database/database.sqlite +php artisan migrate + +# Start development server +php artisan serve +``` + +Visit: http://localhost:8000 + +## Project Structure + +``` +app/ +├── Console/ # Artisan commands +├── Http/ # Controllers & Middleware +├── Models/ # Eloquent models +├── Mod/ # Your custom modules +└── Providers/ # Service providers + +config/ +└── core.php # Core framework configuration + +routes/ +├── web.php # Public web routes +├── api.php # REST API routes +└── console.php # Artisan commands +``` + +## Creating Modules + +```bash +# Create a new module with all features +php artisan make:mod Blog --all + +# Create module with specific features +php artisan make:mod Shop --web --api --admin +``` + +Modules follow the event-driven pattern: + +```php + 'onWebRoutes', + ApiRoutesRegistering::class => 'onApiRoutes', + AdminPanelBooting::class => 'onAdminPanel', + ]; + + public function onWebRoutes(WebRoutesRegistering $event): void + { + $event->routes(fn() => require __DIR__.'/Routes/web.php'); + $event->views('blog', __DIR__.'/Views'); + } +} +``` + +## Core Packages + +| Package | Description | +|---------|-------------| +| `host-uk/core` | Core framework components | +| `host-uk/core-admin` | Admin panel & Livewire modals | +| `host-uk/core-api` | REST API with scopes & webhooks | +| `host-uk/core-mcp` | Model Context Protocol tools | + +## Documentation + +- [Core PHP Framework](https://github.com/host-uk/core-php) +- [Getting Started Guide](https://host-uk.github.io/core-php/guide/) +- [Architecture](https://host-uk.github.io/core-php/architecture/) + +## License + +EUPL-1.2 (European Union Public Licence) diff --git a/app/Http/Controllers/.gitkeep b/app/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Mod/.gitkeep b/app/Mod/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Models/.gitkeep b/app/Models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..452e6b6 --- /dev/null +++ b/app/Providers/AppServiceProvider.php @@ -0,0 +1,24 @@ +handleCommand(new ArgvInput); + +exit($status); diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 0000000..ac5419a --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,23 @@ +withProviders([ + // Core PHP Framework Packages + \Core\CoreServiceProvider::class, + ]) + ->withRouting( + web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', + commands: __DIR__.'/../routes/console.php', + health: '/up', + ) + ->withMiddleware(function (Middleware $middleware) { + // + }) + ->withExceptions(function (Exceptions $exceptions) { + // + })->create(); diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 0000000..38b258d --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,5 @@ + [ + app_path('Core'), + app_path('Mod'), + app_path('Website'), + ], + + 'services' => [ + 'cache_discovery' => env('CORE_CACHE_DISCOVERY', true), + ], + + 'cdn' => [ + 'enabled' => env('CDN_ENABLED', false), + 'driver' => env('CDN_DRIVER', 'bunny'), + ], +]; diff --git a/database/factories/.gitkeep b/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/migrations/.gitkeep b/database/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php new file mode 100644 index 0000000..df6818f --- /dev/null +++ b/database/seeders/DatabaseSeeder.php @@ -0,0 +1,16 @@ + + + + + tests/Unit + + + tests/Feature + + + + + app + + + + + + + + + + + + + + + + diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..49c0612 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..3aec5e2 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,21 @@ + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Send Requests To Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..947d989 --- /dev/null +++ b/public/index.php @@ -0,0 +1,17 @@ +handleRequest(Request::capture()); diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/resources/css/app.css b/resources/css/app.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/resources/css/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/resources/js/app.js b/resources/js/app.js new file mode 100644 index 0000000..e59d6a0 --- /dev/null +++ b/resources/js/app.js @@ -0,0 +1 @@ +import './bootstrap'; diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js new file mode 100644 index 0000000..953d266 --- /dev/null +++ b/resources/js/bootstrap.js @@ -0,0 +1,3 @@ +import axios from 'axios'; +window.axios = axios; +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php new file mode 100644 index 0000000..88808ac --- /dev/null +++ b/resources/views/welcome.blade.php @@ -0,0 +1,65 @@ + + + + + + Core PHP Framework + + + +
+

Core PHP Framework

+

Laravel {{ Illuminate\Foundation\Application::VERSION }} | PHP {{ PHP_VERSION }}

+ +
+ + diff --git a/routes/api.php b/routes/api.php new file mode 100644 index 0000000..15fbf70 --- /dev/null +++ b/routes/api.php @@ -0,0 +1,5 @@ +