Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ninsuo/code-generator-bundle
A visual "maker-bundle" to quickly create code skeletons
https://github.com/ninsuo/code-generator-bundle
Last synced: about 1 month ago
JSON representation
A visual "maker-bundle" to quickly create code skeletons
- Host: GitHub
- URL: https://github.com/ninsuo/code-generator-bundle
- Owner: ninsuo
- License: mit
- Created: 2022-01-19T05:59:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-21T02:54:12.000Z (about 3 years ago)
- Last Synced: 2024-10-28T16:05:02.586Z (3 months ago)
- Language: PHP
- Size: 511 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Code generator
### What is it?
It's a code generator heavily inspired from the Symfony maker, developed in a web interface.
Create snippets:
- Add your context in YAML
- Enrich it with PHP code
- Write down your Twig templatesUse snippets
- Either use "Copy" buttons in the UX
- Or use the interactive maker-like command-lineShare snippets:
- Easily export and import snippets in the UX
- Share snippets in a project using fixtures![intro](docs/images/0-intro.png)
Check out more details and screenshots [here](docs/index.md).
### Standalone install
You can install this generator standalone if needed, just download a new symfony project.
Ensure [symfony cli](https://symfony.com/download) is installed and run:
```
symfony new codegen --full
```You'll need to set up a storage, in `.env` you may uncomment:
```
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
```### Bundle install
#### Use composer
```shell
composer require --dev ninsuo/code-generator-bundle
```or in `composer.json`:
```json
{
"require": {
"ninsuo/code-generator-bundle": "dev-main"
}
}
```#### Add the bundle
The PHP enricher is a beautiful RCE vulnerability, so please enable this bundle in development environment only!
In `config/bundles.php`:
```php
['dev' => true],
];
```#### Add the routing
In `config/routes/annotations.yaml`:
```yaml
snippet:
resource: '@CodeGeneratorBundle/Controller/'
type: annotation
```#### Generate schema
Run the following command:
```shell
php bin/console make:migration
```Edit the generated file to ensure migration will only run on dev environment.
```php
public function up(Schema $schema): void
{
if ('dev' !== $_ENV['APP_ENV']) {
return;
}// ...
}public function down(Schema $schema): void
{
if ('dev' !== $_ENV['APP_ENV']) {
return;
}// ...
}
```Then, run:
```
php bin/console doctrine:migrations:migrate
```#### Run
Run `symfony start` and go to `http://127.0.0.1:8000/snippet` route
### Sharing snippets
Use the import / export feature at the bottom to share snippets with crewmates.
If you are using this bundle inside a project, you can also use fixtures to share snippets:
```php
snippetRepository = $snippetRepository;
}public function load(ObjectManager $manager)
{
$this->snippetRepository->import(
'eyJuIjoiSGVsbG8sIHdvcmxkIiwiYyI6ImZvbzogYmFyIiwiZSI6IiRjb250ZXh0WydiYXonXSA9IHN0cnRvdXBwZXIoJGNvbnRleHRbJ2ZvbyddKTsiLCJmIjpbeyJkIjoiaWYgeW91IHNlYXJjaCBmb3IgbWUsIGknbSBhdCB0aGUge3sgYmF6IH19IiwidCI6IkhlbGxvLCB7eyBmb28gfX0ifV19'
);
}
}
```