{"id":33964134,"url":"https://github.com/spexdw/z-engine","last_synced_at":"2025-12-12T22:57:23.127Z","repository":{"id":325716048,"uuid":"1101970627","full_name":"spexdw/z-engine","owner":"spexdw","description":"A lightweight PHP framework. No bloat, just the essentials you actually need.","archived":false,"fork":false,"pushed_at":"2025-11-22T23:29:00.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-23T00:20:20.514Z","etag":null,"topics":["framework","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spexdw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-22T15:25:14.000Z","updated_at":"2025-11-23T00:06:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/spexdw/z-engine","commit_stats":null,"previous_names":["spexdw/z-engine"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/spexdw/z-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spexdw%2Fz-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spexdw%2Fz-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spexdw%2Fz-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spexdw%2Fz-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spexdw","download_url":"https://codeload.github.com/spexdw/z-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spexdw%2Fz-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27694319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","php"],"created_at":"2025-12-12T22:57:22.451Z","updated_at":"2025-12-12T22:57:23.117Z","avatar_url":"https://github.com/spexdw.png","language":"PHP","readme":"# ZEngine\n\n[![CI](https://github.com/spexdw/z-engine/workflows/CI/badge.svg)](https://github.com/spexdw/z-engine/actions)\n[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.1-8892BF.svg)](https://php.net/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA lightweight PHP framework. No bloat, just the essentials you actually need.\n\n## Why?\n\nI got tired of complex frameworks with thousands of files. ZEngine is simple - you can read the entire source code in an afternoon and understand exactly what's happening.\n\n## What's Included\n\n- **Routing** - Map URLs to functions, add parameters, group routes\n- **Middleware** - Protect routes, handle auth, whatever you need\n- **Database** - Query builder that doesn't get in your way\n- **Services** - Session, cookies, cache, validation, logging etc.\n- **Dependency Injection** - Automatic, no XML configs\n- **Error Pages** - Custom error handling with nice debug screens\n\n## Requirements\n\n- PHP 8.1+\n- Composer\n- That's it\n\n## Installation\n\nCreate a new project:\n\n```bash\ncomposer create-project spexdw/z-engine my-project\ncd my-project\n```\n\nOr clone it directly:\n\n```bash\ngit clone https://github.com/spexdw/z-engine.git my-project\ncd my-project\ncomposer install\n```\n\n## Quick Start\n\n1. Copy `.env.example` to `.env` and set your config\n2. Edit `app/routes.php` to add your routes\n\n```php\n$router-\u003eget('/hello/{name}', function ($name) {\n    return json(['message' =\u003e \"Hello, $name!\"]);\n});\n```\n\nThat's it. No generators, no boilerplate, just write code.\n\n## Routing\n\n```php\n// Basic routes\n$router-\u003eget('/users', function () {\n    return json(['users' =\u003e []]);\n});\n\n$router-\u003epost('/users', function (Request $request) {\n    $data = $request-\u003ejson();\n    return json(['created' =\u003e $data], 201);\n});\n\n// URL parameters\n$router-\u003eget('/users/{id}', function ($id) {\n    return json(['user_id' =\u003e $id]);\n});\n\n// Protect routes with middleware\n$router-\u003eget('/admin', function () {\n    return json(['secret' =\u003e 'data']);\n})-\u003emiddleware(AdminMiddleware::class);\n\n// Group routes\n$router-\u003egroup(['prefix' =\u003e '/api'], function ($router) {\n    $router-\u003eget('/users', fn() =\u003e json([]));\n    $router-\u003eget('/posts', fn() =\u003e json([]));\n});\n```\n\n## Database\n\n```php\n// Query builder\n$users = db()-\u003etable('users')\n    -\u003ewhere('status', 'active')\n    -\u003eorderBy('created_at', 'DESC')\n    -\u003eget();\n\n// Raw queries\n$results = db()-\u003equery('SELECT * FROM users WHERE id = ?', [1]);\n\n// Insert/Update/Delete\ndb()-\u003einsert('users', ['name' =\u003e 'John', 'email' =\u003e 'john@example.com']);\ndb()-\u003eupdate('users', ['status' =\u003e 'active'], ['id' =\u003e 1]);\ndb()-\u003edelete('users', ['id' =\u003e 1]);\n\n// Transactions\ndb()-\u003ebeginTransaction();\ntry {\n    db()-\u003einsert('users', ['name' =\u003e 'John']);\n    db()-\u003ecommit();\n} catch (Exception $e) {\n    db()-\u003erollback();\n}\n```\n\n## Services\n\n```php\n// Session\nsession()-\u003eset('user_id', 123);\n$userId = session()-\u003eget('user_id');\n\n// Cache (5 minutes)\ncache()-\u003eset('key', 'value', 300);\n$value = cache()-\u003eget('key');\n\n// Cookies\ncookie()-\u003eset('theme', 'dark', time() + 3600);\n$theme = cookie()-\u003eget('theme');\n\n// Validation\n$rules = ['email' =\u003e 'required|email', 'age' =\u003e 'min:18'];\n$isValid = validator()-\u003evalidate($data, $rules);\n\n// Logging\nlogger()-\u003eerror('Something broke', ['context' =\u003e 'details']);\n```\n\n## Middleware\n\nCreate a middleware in `app/Middleware`:\n\n```php\nclass AuthMiddleware\n{\n    public function handle(Request $request, Closure $next)\n    {\n        if (!$request-\u003eheader('Authorization')) {\n            return Response::json(['error' =\u003e 'Unauthorized'], 401);\n        }\n        return $next($request);\n    }\n}\n```\n\nUse it:\n\n```php\n$router-\u003eget('/dashboard', function () {\n    return json(['data' =\u003e 'secret']);\n})-\u003emiddleware(AuthMiddleware::class);\n```\n\n## Custom Services\n\nAdd your service to `core/Providers.php`:\n\n```php\nprivate static function registerMyService(Container $container): void\n{\n    $container-\u003esingleton('myservice', function () {\n        return new MyService();\n    });\n}\n```\n\nThen call `self::registerMyService($container);` in the `register()` method.\n\nUse it anywhere:\n\n```php\n$result = app('myservice')-\u003edoSomething();\n```\n\n## Error Handling\n\nSet `APP_DEBUG=true` in `.env` for detailed error pages with code snippets.\n\nSet `APP_DEBUG=false` for production to show clean error pages.\n\nAll errors are logged to `storage/logs/error.log`.\n\n## Contributing\n\nFound a bug? Want a feature? Open an issue or PR. Keep it simple.\n\n## License\n\nMIT. Do whatever you want with it.\n\n## Credits\n\nBuilt by [spexdw](https://github.com/spexdw) because existing frameworks were too complicated :p\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspexdw%2Fz-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspexdw%2Fz-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspexdw%2Fz-engine/lists"}