Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trismegiste/bronze
Code your Proof Of Concept with Swag
https://github.com/trismegiste/bronze
alpinejs closure docker form mongodb picocss poc rainbow-dash symfony-component twig
Last synced: about 1 month ago
JSON representation
Code your Proof Of Concept with Swag
- Host: GitHub
- URL: https://github.com/trismegiste/bronze
- Owner: Trismegiste
- Created: 2023-03-03T12:32:01.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-25T09:58:09.000Z (about 1 year ago)
- Last Synced: 2024-10-13T06:20:53.054Z (2 months ago)
- Topics: alpinejs, closure, docker, form, mongodb, picocss, poc, rainbow-dash, symfony-component, twig
- Language: PHP
- Homepage:
- Size: 154 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bronze
## Code your Proof Of Concept with SwagSurvival kit for your proof of concepts & quick n dirty tests :
* Start a PHP project in 10 seconds flat
* Feel like **Symfony 6** but without model, entity, database config, form class...
* Form-driven development
* The POC is validated ? Now you can extract entity informations for the final project built on **Symfony 6**
* No security at all, not intended for production **AT ALL**.It includes :
* PHP 8.1
* Symfony Kernel & HttpFoundation 6.3
* Symfony Forms with Validators & CSRF
* Twig 3.x
* MongoDb 6.0
* PicoCSS because it's the best CSS framework
* AlpineJS because of climate change
* PhpUnit 9.x# Install
```bash
$ docker compose build && docker compose up
```# Access to app
```bash
$ firefox http://127.0.0.1:8000/
```# Hack n slash
## Run tests
```bash
$ docker exec -it bronze-symfony-1 vendor/bin/phpunit
```## Run mongo shell
```bash
$ docker exec -it bronze-mongo-1 mongosh
```# Customize
## Edit ```index.php```
### Run a full business app with LCRUD :
```php
$app = new BusinessApp();// database name : bronze
// entity name and collection name : bicycle$app->crud('bronze', 'bicycle', function (FormBuilderInterface $builder) {
return $builder
->add('brand', TextType::class)
->add('size', TextType::class)
->add('color', TextType::class)
->add('save', SubmitType::class)
->getForm();
});$app->run();
```This method adds 5 routes :
* ```/bicycle``` for list
* ```/bicycle/new/create``` for creating a new bicycle
* ```/bicycle/1234/show``` for viewing bicycle 1234
* ```/bicycle/1234/edit``` for editing bicycle 1234
* ```/bicycle/1234/delete``` for deleting bicycle 1234It uses a entity with magic accessors/mutators but you can use your own entity, your own form and your own routes.
### If your app doesn't need form nor CRUD
Homepage '/' with a template ```index.html.twig``` stored in ```./templates``` :
```php
$app = new \Trismegiste\Bronze\Core\WebApp();$app->get('/', function () {
return $this->render('index.html.twig', ['message' => 'Hi Mom !']);
});$app->run();
```
### If your app does not need Twig
```php
$app = new Trismegiste\Bronze\Core\App();$app->get('/', function () {
return new \Symfony\Component\HttpFoundation\JsonResponse(['message' => 'Hi Mom !']);
});$app->run();
```All controllers are Closures but they are bound to feel like you're using a AbstractController from Symfony.
## Twig
Customize templates in ```./templates/bicycle``` for the entity name **bicycle** :
* list.html.twig
* show.html.twig
* form.html.twig
* create.html.twig
* edit.html.twig
* delete.html.twigIf one of these template does not exist, twig falls back to generic templates in ```./Resources/templates```