Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hubertkuch/avocado
Simple PHP framework which implements ORM and routing
https://github.com/hubertkuch/avocado
api-server framework orm orm-framework router routing
Last synced: 27 days ago
JSON representation
Simple PHP framework which implements ORM and routing
- Host: GitHub
- URL: https://github.com/hubertkuch/avocado
- Owner: HubertKuch
- Created: 2022-03-24T21:21:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T15:18:37.000Z (over 1 year ago)
- Last Synced: 2024-04-16T11:10:19.300Z (8 months ago)
- Topics: api-server, framework, orm, orm-framework, router, routing
- Language: PHP
- Homepage: https://avocadoframework.com
- Size: 392 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Avocado Project
Avocado is easy to learn and use framework for PHP8.1 or higher. Heavily inspired by Spring Boot.## Goals
- Easy and fast way to create applications in PHP.
- Easy extensible with new features.
- OOP based application.
- High abstraction level especially database connection is only a detail.
- Testable applications.
- Easy configured app.
- Fully use PHP attributes from PHP8.0.## Features
- Rest controllers.
- ORM.
- Configuration properties in `application.{yaml,json}` file.
- Database connection is only a detail.
- Easy writing integration tests.
- Easy file uploading.
- JSON serializing and deserializing.
- Many allowed databases - to connect you only need to set driver class.
- Middleware.
- Custom attributes (annotations) interceptors.
- Parsing request body, params, query, files, attributes into variables (also objects).
- Fully support for enums.
- Abstraction level for database.
- Errors and exceptions handlers.
- Dependency injection.## Is Avocado for you?
If you like Java environment (especially Spring boot), OOP, fast
development process or fully tests application Avocado is for you.## First app
You need to redirect all request into main file. In Apache, you can do it
in `.htaccess` file like this:
```apacheconf
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
```or in NGINX
```apacheconf
server {
listen 80 default_server;location / {
rewrite ^ /index.php last
}
}
```Quick start
```php
class Message {
public function __construct(private string $message){}
}#[RestController]
class GrettingController {
// response will be JSON { "message": "Hello, !" }
#[GetMapping("/gretting/:name")]
public function greet(#[RequestParam(name: "name", defaulValue: "John")] string $name): Message {
return new Message("Hello, " . $name . "!");
}
}#[Avocado]
class DemoApplication {public static function run(): void {
Application::run(__DIR__);
}
}DemoApplication::run();
```## Plans for future
- Create a similar system for JPA repositories.
- Caching data in Redis database.## License
Open Source on Apache2.0