Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# Bronze
## Code your Proof Of Concept with Swag

Survival 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 1234

It 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.twig

If one of these template does not exist, twig falls back to generic templates in ```./Resources/templates```