{"id":33974554,"url":"https://github.com/nextphp-projects/nextphp","last_synced_at":"2025-12-13T01:46:41.757Z","repository":{"id":246474843,"uuid":"821242153","full_name":"nextphp-projects/nextphp","owner":"nextphp-projects","description":"NextPHP is a next-generation, lightweight PHP framework designed for rapid web application development. Optimized for modern cloud environments, it excels in speed, performance, and efficiency, making it the ideal choice for developers aiming to build scalable and secure applications swiftly.","archived":false,"fork":false,"pushed_at":"2024-12-12T11:58:44.000Z","size":59,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T21:50:38.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextphp-projects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSEmd","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}},"created_at":"2024-06-28T05:50:58.000Z","updated_at":"2025-06-09T01:36:21.000Z","dependencies_parsed_at":"2024-06-28T06:50:28.628Z","dependency_job_id":"e5c213a2-c30b-4fc9-beed-2379375b9807","html_url":"https://github.com/nextphp-projects/nextphp","commit_stats":null,"previous_names":["nextphp-projects/nextphp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nextphp-projects/nextphp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextphp-projects%2Fnextphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextphp-projects%2Fnextphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextphp-projects%2Fnextphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextphp-projects%2Fnextphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextphp-projects","download_url":"https://codeload.github.com/nextphp-projects/nextphp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextphp-projects%2Fnextphp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27697921,"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":[],"created_at":"2025-12-13T01:46:41.201Z","updated_at":"2025-12-13T01:46:41.751Z","avatar_url":"https://github.com/nextphp-projects.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NextPHP | Next Generation PHP Framework\n\n![Patreon](https://img.shields.io/static/v1?message=Patreon\u0026logo=patreon\u0026label=\u0026color=F96854\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n![Twitter](https://img.shields.io/static/v1?message=Twitter\u0026logo=twitter\u0026label=\u0026color=1DA1F2\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n![Codepen](https://img.shields.io/static/v1?message=Codepen\u0026logo=codepen\u0026label=\u0026color=000000\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n![Stackoverflow](https://img.shields.io/static/v1?message=Stackoverflow\u0026logo=stackoverflow\u0026label=\u0026color=FE7A16\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n![Slack](https://img.shields.io/static/v1?message=Slack\u0026logo=slack\u0026label=\u0026color=4A154B\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n![LinkedIn](https://img.shields.io/static/v1?message=LinkedIn\u0026logo=linkedin\u0026label=\u0026color=0077B5\u0026logoColor=white\u0026labelColor=\u0026style=for-the-badge)\n\n## About NextPHP\n\nNextPHP is a next-generation, lightweight PHP framework designed for rapid web application development. Optimized for modern cloud environments, it excels in speed, performance, and efficiency, making it the ideal choice for developers aiming to build scalable and secure applications swiftly.\n\n### Key Features\n\n- **Agile and Lean:** Ideal for rapid MVP development with minimal setup.\n- **Cloud-Ready:** Runs seamlessly on any PHP hosting, ensuring high performance.\n- **Integrated Core Features:** Built-in error handling, logging, email, JWT authentication, and more.\n- **Minimalist Architecture:** Lightweight and efficient, reducing resource usage.\n- **RESTful API Support:** Robust and easy-to-use API creation.\n\n### Mission\n\nOur mission is to provide a lightweight, easy-to-use PHP framework that helps developers and startups quickly bring their ideas to life. We believe in simplicity, efficiency, and delivering value without unnecessary complexity.\n\n### Vision\n\nWe envision a world where developers can focus on building innovative solutions without being bogged down by complex setups and configurations. NextPHP aims to be the go-to framework for rapid development and agile methodologies.\n\n### Why NextPHP?\n\nIn today’s digital transformation era, the speed of development, application performance, and resource efficiency are crucial. NextPHP addresses these needs by offering:\n\n- **Simplicity:** Quick and easy setup, no extensive configurations.\n- **Performance:** High-speed execution and low resource consumption.\n- **Flexibility:** Adaptable for both simple web apps and complex APIs.\n- **Community and Support:** Active community with professional support options.\n\n### Development History\n\nNextPHP evolved from LeanPHP, NovaPHP, and NGPHP, each bringing unique strengths such as minimalism, optional composer support, and a fully modular architecture. NextPHP combines the strengths of its predecessors with comprehensive support for modern web development needs, optimized for cloud-based projects.\n\n### Packages\n\nNextPHP offers a range of packages to enhance functionality and streamline development:\n\n- **nextphp/rest:** - [Nextphp\\Data](https://github.com/nextphp-projects/rest): RESTful API operations. \n- **nextphp/data:** - [Nextphp\\Rest](https://github.com/nextphp-projects/data): CRUD and All operations and database adapters.\n- **nextphp/jwt:**  - [Nextphp\\JWT](https://github.com/nextphp-projects/data): JWT package\n- **nextphp/logging:** Logging operations.\n- **nextphp/reporting:** Reporting functionalities.\n- **nextphp/mail:** Email operations.\n- **nextphp/auth:** Authorization and authentication.\n- **nextphp/jwt:** JWT-based authentication.\n- **nextphp/testing:** Testing operations.\n- **nextphp/qa:** Quality assurance and testing.\n- **nextphp/cache:** Caching operations.\n- **nextphp/queue:** Background jobs and task queues.\n- **nextphp/config:** Application configurations.\n- **nextphp/files:** File management and uploads.\n- **nextphp/uploads:** File upload operations.\n\n## Comparison with Other Frameworks\n\nUnlike some other frameworks that can be cumbersome and resource-intensive, NextPHP is designed to be lean and efficient. This means faster development times, lower resource consumption, and reduced hosting costs.\n\n| Feature                               | NextPHP               | Other Frameworks      |\n|---------------------------------------|-----------------------|-----------------------|\n| Easy Setup \u0026 Rapid Development        | ★★★★★                 | ★★★                   |\n| Integrated Core Features              | ★★★★★                 | ★★★★                  |\n| Ease of Learning                      | ★★★★★                 | ★★★                   |\n| Performance \u0026 Speed                   | ★★★★★                 | ★★★                   |\n| Community Support                     | ★★★★                  | ★★★★★                 |\n| Ideal for Startups                    | ★★★★★                 | ★★★                   |\n| Download \u0026 Use Capability             | ★★★★★                 | ★★★                   |\n| Source Code Size                      | ★★★★★ (Kilobytes)     | ★★ (Megabytes)        |\n| RESTful API Support                   | ★★★★★                 | ★★★★                  |\n\n### Unique Advantages of NextPHP\n\n- **No Bloat:** Only include what you need. This makes NextPHP exceptionally fast and responsive.\n- **Resource Efficiency:** Optimized for low resource consumption, making it perfect for cloud environments and cost-effective deployments.\n- **Rapid Prototyping:** Quickly go from concept to prototype with minimal overhead.\n- **Scalability:** Designed with scalability in mind, making it easy to grow your application as your business expands.\n- **Security:** Built-in security features ensure your applications are protected from common vulnerabilities.\n\n# NextPHP Framework Usage Documentation\n\n## Overview\nThe NextPHP Framework is a modern and lightweight PHP framework. Designed for high performance and scalability, it offers a comprehensive set of tools and libraries to accelerate the development process. The framework includes various packages such as NextPHP Rest and NextPHP Data.\n\n## Features\n- Supports all RESTful methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, CONNECT, PRI)\n- Response formats: JSON, XML, HTML, TEXT, CSV\n- Attribute-based route definitions\n- Middleware and JWT support\n- Attribute-based entity definitions with ORM\n- Direct SQL query capabilities\n- Relationship management (OneToMany, ManyToOne, etc.)\n- Easy integration with existing projects\n\n## Installation\n\n### Installation with Composer\nTo add the NextPHP package to your project, run the following command using Composer:\n\n```bash\ncomposer require nextphp/nextphp\n```\n\n## Basic Usage\nNextPHP comes ***with an example project demonstrating a full multi-layered architecture CRUD operation*** with ***User*** and ***Post*** examples.\n\n\n### Defining Entities\nEntities represent the tables in your database. Use attributes to define the properties and their types.\n\n```php\n\u003c?php\nnamespace Example;\n\nuse NextPHP\\Data\\Persistence\\Column;\nuse NextPHP\\Data\\Persistence\\Entity;\nuse NextPHP\\Data\\Persistence\\GeneratedValue;\nuse NextPHP\\Data\\Persistence\\Id;\nuse NextPHP\\Data\\Persistence\\Table;\n\n#[Entity(name: \"users\")]\nclass User\n{\n    #[Id]\n    #[Column('INT AUTO_INCREMENT PRIMARY KEY', false)]\n    public int $id;\n\n    #[Column('VARCHAR(255)', false)]\n    public string $name;\n\n    #[Column('VARCHAR(255)', false)]\n    public string $email;\n\n    #[Column('VARCHAR(255)', false)]\n    public string $password;\n\n    // getters and setters\n}\n```\n\n### Advanced Entity Usage\nRelationships OneToMany, OnetoOne, ManyToOne and ManytoMany. \nDefine relationships using attributes.\n\n```php\n\u003c?php\nnamespace Example;\n\nuse NextPHP\\Data\\Persistence\\Column;\nuse NextPHP\\Data\\Persistence\\Entity;\nuse NextPHP\\Data\\Persistence\\GeneratedValue;\nuse NextPHP\\Data\\Persistence\\Id;\nuse NextPHP\\Data\\Persistence\\Table;\n\n#[Entity(name: \"users\")]\nclass Post\n{\n    #[Id]\n    #[Column('INT AUTO_INCREMENT PRIMARY KEY', false)]\n    public int $id;\n\n    #[Column('VARCHAR(255)', false)]\n    public string $title;\n\n    #[Column('TEXT', false)]\n    public string $content;\n\n    #[Column('INT', false)]\n    public int $user_id;\n\n    // example for ManyToMany, OneToMany etc.\n    #[ManyToOne(targetEntity: User::class, inversedBy: 'posts')]\n    private User $user;\n\n    // getters and setters\n}\n```\n\n### Using Repository\nRepositories handle database operations for entities. Extend ***BaseRepository*** and specify the entity class.\n\n```php\n\u003c?php\nnamespace Example;\n\nuse NextPHP\\Data\\BaseRepository;\n\n#[Repository(entityClass: User::class)]\nclass UserRepository extends BaseRepository\n{\n    // No need for constructor\n}\n```\n\n### Service Layer\nServices provide business logic and interact with repositories.\n\n```php\n\u003c?php\nnamespace Example;\n\n#[Service(description: 'User management service')]\nclass UserService\n{\n    private UserRepository $userRepository;\n\n    public function __construct(UserRepository $userRepository)\n    {\n        $this-\u003euserRepository = $userRepository;\n    }\n\n    #[Transactional]\n    public function registerUser(array $userData): User\n    {\n        $user = new User();\n        $user-\u003ename = $userData['name'];\n        $user-\u003eemail = $userData['email'];\n        $user-\u003epassword = password_hash($userData['password'], PASSWORD_DEFAULT);\n\n        $userArray = [\n            'name' =\u003e $user-\u003ename,\n            'email' =\u003e $user-\u003eemail,\n            'password' =\u003e $user-\u003epassword,\n        ];\n\n        $this-\u003euserRepository-\u003esave($userArray);\n\n        return $user;\n    }\n\n    public function getAllUsers(): array\n    {\n        return $this-\u003euserRepository-\u003efindAll();\n    }\n\n    public function getUserById(int $id): ?User\n    {\n        $userArray = $this-\u003euserRepository-\u003efind($id);\n        if (!$userArray) {\n            return null;\n        }\n\n        $user = new User();\n        $user-\u003eid = $userArray['id'];\n        $user-\u003ename = $userArray['name'];\n        $user-\u003eemail = $userArray['email'];\n        $user-\u003epassword = $userArray['password'] ?? '';\n\n        return $user;\n    }\n\n    public function updateUser(int $id, array $data): ?User\n    {\n        $user = $this-\u003egetUserById($id);\n        if (!$user) {\n            return null;\n        }\n\n        foreach ($data as $key =\u003e $value) {\n            if (property_exists($user, $key)) {\n                $user-\u003e$key = $value;\n            }\n        }\n\n        $userArray = get_object_vars($user);\n        $this-\u003euserRepository-\u003eupdate($id, $userArray);\n\n        return $user;\n    }\n\n    public function deleteUser(int $id): bool\n    {\n        $user = $this-\u003egetUserById($id);\n        if (!$user) {\n            return false;\n        }\n\n        $this-\u003euserRepository-\u003edelete($id);\n\n        return true;\n    }\n}\n```\n\n### Using Resource\nThis is an example project demonstrating the usage of the NextPHP Rest package, which includes routing and HTTP handling capabilities.\nBasic Usage Defining Routes Define routes using attributes to map HTTP methods to controller actions.\n\n```php\n\u003c?php\n\nnamespace NextPHP\\App\\Resource;\n\nuse NextPHP\\Rest\\Http\\Request;\nuse NextPHP\\Rest\\Http\\Response;\nuse NextPHP\\Rest\\Http\\Get;\nuse NextPHP\\Rest\\Http\\Post;\nuse NextPHP\\Rest\\Http\\Put;\nuse NextPHP\\Rest\\Http\\Delete;\nuse NextPHP\\Rest\\Http\\Patch;\nuse NextPHP\\Rest\\Http\\RouteGroup;\nuse NextPHP\\Rest\\Http\\Middleware;\nuse NextPHP\\App\\Middleware\\RequestLoggerMiddleware;\nuse NextPHP\\App\\Service\\UserService;\n\n#[RouteGroup('/api')]\n// #[Middleware(AuthMiddleware::class)]\nclass UserResource\n{\n    private UserService $userService;\n\n    public function __construct(UserService $userService)\n    {\n        $this-\u003euserService = $userService;\n    }\n\n    #[Get('/users')]\n    public function getAllUsers(Request $request, Response $response)\n    {\n        $users = $this-\u003euserService-\u003egetAllUsers();\n        return $response-\u003ewithJSON(['users' =\u003e $users]);\n    }\n\n    #[Get('/users2')]\n    public function getAllUsers2(Request $request, Response $response)\n    {\n        // Middleware'i burada çağırıyoruz\n        $middleware = new RequestLoggerMiddleware();\n        $middleware-\u003ehandle($request, function($request) use ($response) {\n            $users = $this-\u003euserService-\u003egetAllUsers();\n            return $response-\u003ewithJSON(['users' =\u003e $users]);\n        });\n        \n        // Middleware handle işlemi sonucu response döner\n        return $response;\n    }\n\n    #[Get('/users/{id}')]\n    public function getUserById(Request $request, Response $response, $id)\n    {\n        $user = $this-\u003euserService-\u003egetUserById((int)$id);\n        if ($user) {\n            return $response-\u003ewithJSON($user);\n        } else {\n            return $response-\u003ewithStatus(404)-\u003ewithJSON(['error' =\u003e 'User not found']);\n        }\n    }\n\n    #[Post('/users')]\n    public function createUser(Request $request, Response $response)\n    {\n        $data = json_decode($request-\u003egetBody(), true);\n        if (json_last_error() !== JSON_ERROR_NONE) {\n            return $response-\u003ewithStatus(400)-\u003ewithJSON(['error' =\u003e 'Invalid JSON provided']);\n        }\n\n        $user = $this-\u003euserService-\u003eregisterUser($data);\n        return $response-\u003ewithStatus(201)-\u003ewithJSON($user);\n    }\n\n    #[Put('/users/{id}')]\n    public function updateUser(Request $request, Response $response, $id)\n    {\n        $data = json_decode($request-\u003egetBody(), true);\n        if (json_last_error() !== JSON_ERROR_NONE) {\n            return $response-\u003ewithStatus(400)-\u003ewithJSON(['error' =\u003e 'Invalid JSON provided']);\n        }\n    \n        $user = $this-\u003euserService-\u003eupdateUser((int)$id, $data);\n        if ($user) {\n            return $response-\u003ewithJSON($user);\n        } else {\n            return $response-\u003ewithStatus(404)-\u003ewithJSON(['error' =\u003e 'User not found']);\n        }\n    }\n    \n    #[Patch('/users/{id}')]\n    public function patchUser(Request $request, Response $response, $id)\n    {\n        $data = json_decode($request-\u003egetBody(), true);\n        if (json_last_error() !== JSON_ERROR_NONE) {\n            return $response-\u003ewithStatus(400)-\u003ewithJSON(['error' =\u003e 'Invalid JSON provided']);\n        }\n    \n        $user = $this-\u003euserService-\u003epatchUser((int)$id, $data);\n        if ($user) {\n            return $response-\u003ewithJSON($user);\n        } else {\n            return $response-\u003ewithStatus(404)-\u003ewithJSON(['error' =\u003e 'User not found']);\n        }\n    }\n\n    #[Delete('/users/{id}')]\n    public function deleteUser(Request $request, Response $response, $id)\n    {\n        $success = $this-\u003euserService-\u003edeleteUser((int)$id);\n        if ($success) {\n            return $response-\u003ewithStatus(204);\n        } else {\n            return $response-\u003ewithStatus(404)-\u003ewithJSON(['error' =\u003e 'User not found']);\n        }\n    }\n}\n```\n\n\n## Generate the index.php file\n\nTo start the NextPHP package, you can create an `index.php` file and use the service layer to perform various CRUD operations. Here is an example of how you can do this:\n\n### Example index or example.php\n\n```php\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse NextPHP\\Rest\\DI\\Container;\nuse NextPHP\\Rest\\Router;\nuse NextPHP\\Rest\\Http\\Request;\nuse NextPHP\\Rest\\Http\\Response;\nuse NextPHP\\App\\Resource\\UserResource;\nuse NextPHP\\App\\Resource\\PostResource;\n\n$container = new Container();\n\n$router = new Router([\n    'baseUri' =\u003e '/nextphp-beta',\n    'allowedOrigins' =\u003e [\n        'http://allowed-origin.com' =\u003e ['GET', 'POST'],\n        'http://another-allowed-origin.com' =\u003e ['GET', 'PUT'],\n        '*' =\u003e ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PRI']\n    ]\n], $container);\n\n// DI\n$router-\u003eregisterRoutesFromController(UserResource::class);\n$router-\u003eregisterRoutesFromController(PostResource::class);\n\n$uri = $_SERVER['REQUEST_URI'];\n$method = $_SERVER['REQUEST_METHOD'];\n\n$request = new Request($method, $uri, getallheaders(), file_get_contents('php://input'), $_GET, $_POST);\n$response = new Response();\n\n$response = $router-\u003edispatch($request, $response);\n\nif ($response) {\n    http_response_code($response-\u003egetStatusCode());\n    foreach ($response-\u003egetHeaders() as $name =\u003e $value) {\n        header(\"$name: $value\");\n    }\n    echo $response-\u003egetBody();\n} else {\n    http_response_code(500);\n    echo json_encode(['error' =\u003e 'Internal Server Error', 'message' =\u003e 'No response returned.']);\n}\n```\n\n### Project Architecture\nExample for your Project Structure\n\n```code\nexample/\n├── src/\n│   ├── Entity/\n│   │   ├── User.php\n│   │   ├── Post.php\n│   ├── Repository/\n│   │   ├── UserRepository.php\n│   │   ├── PostRepository.php\n│   ├── Service/\n│   │   ├── UserService.php\n│   │   ├── PostService.php\n│   ├── Resource/\n│   │   ├── UserResource.php\n│   │   ├── PostResource.php\n├── index.php\n├── composer.json\n└── README.md\n```\n\n## Contributing\n\nWe welcome contributions! Here’s how you can help:\n\n- **Report Issues:** Found a bug? Report it on GitHub.\n- **Suggest Features:** Have an idea? Share it with us.\n- **Submit Pull Requests:** Improve the codebase.\n- **Enhance Documentation:** Help us improve our docs.\n\nFor more details, see our [Contribution Guidelines](contribution.md).\n\n## Resources\n\n- [Official Website](https://nextphp.io)\n- [GitHub Repository](https://github.com/nextphp-projects/nextphp)\n- [Documentation](https://nextphp.io/documentation)\n\n## Join Our Community\n\n- **Twitter:** Follow us on [Twitter](https://twitter.com/NextPHPOfficial)\n- **Discord:** Join our [Discord](https://discord.gg/nextphp) community.\n\n## Contact Us\n\n- **Email:** support@nextphp.io\n- **Forum:** [NextPHP Mastodon](https://mastodon.social/@nextphp)\n- **GitHub Issues:** [NextPHP GitHub](https://github.com/nextphp-projects/nextphp/issues)\n\nThank you for being part of the NextPHP community!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextphp-projects%2Fnextphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextphp-projects%2Fnextphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextphp-projects%2Fnextphp/lists"}