Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/effectra/generator
The Effectra/Generator package provides a set of tools for generating PHP class files and configuration files.
https://github.com/effectra/generator
config-file generate-classes generate-code generate-config-file generate-file generator php template
Last synced: 5 days ago
JSON representation
The Effectra/Generator package provides a set of tools for generating PHP class files and configuration files.
- Host: GitHub
- URL: https://github.com/effectra/generator
- Owner: effectra
- Created: 2023-05-24T09:51:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-13T21:17:24.000Z (over 1 year ago)
- Last Synced: 2024-12-08T08:47:18.601Z (26 days ago)
- Topics: config-file, generate-classes, generate-code, generate-config-file, generate-file, generator, php, template
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Effectra\Generator
The Effectra\Generator package provides a set of tools for generating PHP class files and configuration files.
## Installation
You can install the package via Composer:
```bash
composer require effectra/generator
```## Usage
### Generate Class
To generate a PHP class file using the GeneratorClass class, follow these steps:
1. Create an instance of the Creator class:
```php
$creator = new Creator();
```2. Create an instance of the GeneratorClass class, providing the creator and the desired class name:
```php
$generator = new GeneratorClass($creator, 'MyClass');
```3. Customize the class by adding properties, methods, and other elements using the available methods provided by the GeneratorClass and Creator classes.
4. Generate the PHP code for the class:
```php
$template = $generator->generate();
```5. Save the generated code to a file:
```php
$template->save('/path/to/MyClass.php');
```### Generate Config File
To generate a configuration file using the GeneratorConfigFile class, follow these steps:
1. Create an instance of the Creator class:
```php
$creator = new Creator();
```2. Create an instance of the GeneratorConfigFile class, providing the creator and the ConfigFile instance:
```php
$configFile = new ConfigFile('/path/to/config.php');
$generator = new GeneratorConfigFile($creator, $configFile);
```3. Generate a new section in the configuration file:
```php
$section = 'database';
$config = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'mydatabase',
'username' => 'myusername',
'password' => 'mypassword',
];$template = $generator->createSection($section, $config);
```4. Save the updated configuration file:
```php
$template->save('/path/to/config.php');
```## Contributing
Contributions are welcome! If you find any issues or would like to suggest new features, please open an issue on the [GitHub repository](https://github.com/effectra/generator).
## License
This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).