allekslar/monofony-demo-backend
Install the Package
composer require allekslar/monofony-demo-backend
Run the post-install script to copy the routing file:
composer run-script post-install -d ./vendor/allekslar/monofony-demo-backend
Extend config/bundles.php
Add the required bundles:
Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle::class => ['all' => true],
Sylius\Bundle\LocaleBundle\SyliusLocaleBundle::class => ['all' => true],
Run Database & Fixtures
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
bin/console assets:install
bin/console doctrine:fixtures:load -n
Access Admin Panel
admin@example.comadminThe package extends Monofony/Skeleton with API endpoints for demo purposes. Test the API immediately:
curl -X GET http://your-app/api/
Verify CORS is enabled (via nelmio/cors-bundle) for frontend integration.
Leverage API Platform
The package uses API Platform (api-platform/core). Extend existing resources by:
src/DataFixtures/ or src/Entity/.#[ApiResource]:
use ApiPlatform\Metadata\ApiResource;
#[ApiResource]
class DemoEntity { ... }
Workflow Integration
The package includes symfony/workflow for state machines. Customize workflows in config/workflows/:
# config/workflows/demo_workflow.yaml
app.demo_workflow:
support:
- { transition: 'publish', from: 'draft' }
Messenger for Async Tasks
Use Symfony Messenger (symfony/messenger) for background jobs:
use Symfony\Component\Messenger\MessageBusInterface;
public function __construct(private MessageBusInterface $bus) {}
$this->bus->dispatch(new DemoMessage());
Taxonomy & Locale
Use SyliusTaxonomyBundle for hierarchical data (e.g., categories) and SyliusLocaleBundle for multilingual support:
use Sylius\Component\Taxonomy\Model\TaxonInterface;
$taxon = $this->taxonRepository->findOneBy(['slug' => 'demo-category']);
Menu Extension
The package depends on allekslar/monofony-menu-extension. Customize menus via YAML:
# config/menu/demo_menu.yaml
demo_menu:
items:
- label: 'Demo'
route: 'api_demo_index'
Database Schema Conflicts
doctrine:migrations:diff is run after extending entities to avoid schema errors.bin/console cache:clear
CORS Misconfiguration
nelmio_cors config in .env:
CORS_ALLOW_ORIGIN=^https?://localhost:\d+$
Workflow Transitions
bin/console debug:workflow app.demo_workflow
API Platform Debugging Enable debug toolbar and check:
bin/console debug:api
Doctrine Extensions
For stof/doctrine-extensions-bundle (e.g., Sluggable), validate slugs:
use Gedmo\Sluggable\Util\Urlizer;
$slug = Urlizer::urlize($entity->getName());
Custom Fixtures
Override fixtures in src/DataFixtures/ to seed demo data:
use Doctrine\Bundle\FixturesBundle\Fixture;
class CustomDemoFixtures extends Fixture {
public function load(ObjectManager $manager) {
$demo = new DemoEntity();
$manager->persist($demo);
$manager->flush();
}
}
Event Subscribers
Listen to API Platform events (e.g., ApiPlatform\Symfony\EventListener\EventPriorities::PRE_WRITE):
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class DemoSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
'api_platform.entity.persist' => ['onPersist', 100],
];
}
}
Uninstallation Always run the removal script to clean up routes/config:
composer run-script remove -d ./vendor/allekslar/monofony-demo-backend
How can I help you explore Laravel packages today?