onramplab / php-content-generator
A content generator for PHP
Installs: 620
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 7
Forks: 1
Open Issues: 0
pkg:composer/onramplab/php-content-generator
Requires
- php: >=8.1
- mustache/mustache: ^2.13
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.0
README
ContentGenerator is a PHP package designed to manage and generate content using templates and contexts.
Installation
To install the package, use Composer:
composer require onramplab/php-content-generator
Usage
Here's a basic example of how to use the ContentGenerator:
use ContentGenerator\Application\ContentGenerator; use ContentGenerator\Application\ContextManager; use ContentGenerator\Application\TemplateManager; use ContentGenerator\Domain\Context\DefaultContextDataProvider; // Initialize managers $contextManager = new ContextManager(); $templateManager = new TemplateManager(); // Create ContentGenerator instance $contentGenerator = new ContentGenerator($contextManager, $templateManager); // Register a context $contentGenerator->registerContext('name', new DefaultContextDataProvider('name')); // Register a template $contentGenerator->registerTemplate('greeting', 'Hello, {{ name }}!'); // Generate content $content = $contentGenerator->generateContent('greeting'); echo $content; // Outputs: Hello, name!
Testing
To run the tests, use PHPUnit:
php vendor/bin/phpunit
Ensure that Xdebug is properly configured if you encounter any issues related to debugging.