Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Monofony Demo Backend Laravel Package

allekslar/monofony-demo-backend

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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
    
  2. Extend config/bundles.php Add the required bundles:

    Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle::class => ['all' => true],
    Sylius\Bundle\LocaleBundle\SyliusLocaleBundle::class => ['all' => true],
    
  3. Run Database & Fixtures

    bin/console doctrine:migrations:diff
    bin/console doctrine:migrations:migrate
    bin/console assets:install
    bin/console doctrine:fixtures:load -n
    
  4. Access Admin Panel

    • Username: admin@example.com
    • Password: admin

First Use Case: API Endpoints

The 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.


Implementation Patterns

Workflow: Extending API Resources

  1. Leverage API Platform The package uses API Platform (api-platform/core). Extend existing resources by:

    • Creating new DTOs (Data Transfer Objects) in src/DataFixtures/ or src/Entity/.
    • Annotating entities with #[ApiResource]:
      use ApiPlatform\Metadata\ApiResource;
      
      #[ApiResource]
      class DemoEntity { ... }
      
  2. 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' }
    
  3. 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());
    

Integration Tips

  • 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'
    

Gotchas and Tips

Pitfalls

  1. Database Schema Conflicts

    • Ensure doctrine:migrations:diff is run after extending entities to avoid schema errors.
    • If fixtures fail, clear the cache:
      bin/console cache:clear
      
  2. CORS Misconfiguration

    • Verify nelmio_cors config in .env:
      CORS_ALLOW_ORIGIN=^https?://localhost:\d+$
      
  3. Workflow Transitions

    • Debug workflows with:
      bin/console debug:workflow app.demo_workflow
      

Debugging Tips

  • 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());
    

Extension Points

  1. 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();
        }
    }
    
  2. 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],
            ];
        }
    }
    
  3. Uninstallation Always run the removal script to clean up routes/config:

    composer run-script remove -d ./vendor/allekslar/monofony-demo-backend
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware