https://github.com/bottledcode/swytch-framework
The Smart PHP Framework
https://github.com/bottledcode/swytch-framework
framework php php-framework
Last synced: 2 months ago
JSON representation
The Smart PHP Framework
- Host: GitHub
- URL: https://github.com/bottledcode/swytch-framework
- Owner: bottledcode
- License: mit
- Created: 2023-02-18T09:07:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-13T22:13:10.000Z (about 2 years ago)
- Last Synced: 2025-09-26T17:02:15.057Z (6 months ago)
- Topics: framework, php, php-framework
- Language: PHP
- Homepage: https://framework.getswytch.com/
- Size: 600 KB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Swytch Framework
The Swytch Framework is a new, fledgling, but powerful framework allowing you to write HTML inline with your application
logic, including API endpoints. It is built on top of [htmx](https://htmx.org/) for the browser-side heavy-lifting,
and a custom, streaming HTML5 parser, to handle the HTML and escaping.
Features:
- Write HTML inline with your PHP code, relying on context-aware escaping.
- Keep you API logic near the HTML that uses it.
- Application routing via HTML (similar to ReactRouter).
- Automatic CSRF protection.
- Context-Aware escaping.
- Automatic HTML5 validation.
- Authorization and authentication aware routing and rendering.
- Browser cache control.
- Builtin support for translations.
> NOTE:
> This is currently pre-production software and is not recommended for production use.
## Example Apps
The following are some example apps using the Swytch Framework:
### [Once](https://github.com/bottledcode/once)
Check it out live on [once.getswytch.com](https://once.getswytch.com/). This is a secret message app.
### [Authentication](https://github.com/bottledcode/swytch-auth)
This app provides a simple authentication system by emailing passwords. It provides Kubernetes ingress authentication.
## Example Component
```php
#[\Bottledcode\SwytchFramework\Template\Attributes\Component('example')]
class ExampleComponent {
use \Bottledcode\SwytchFramework\Template\Traits\RegularPHP;
use \Bottledcode\SwytchFramework\Template\Traits\Htmx;
#[\Bottledcode\SwytchFramework\Router\Attributes\Route(\Bottledcode\SwytchFramework\Router\Method::POST, '/api/number')]
public function getNumber(string $name, string $number): int {
return $this->render($name, random_int(0, 100));
}
public function render(string $name, int $number = null): string {
$this->begin();
?>
Hello, {= $name ?>}
} />
Here is a random number: {= $number ?>}
Generate a new random number
end();
}
}
```