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

Message Bundle Laravel Package

cunningsoft/message-bundle

View on GitHub
Deep Wiki
Context7

Installation

  1. Add the following to your composer.json file:

    // composer.json
    {
        // ...
        require: {
            // ...
            "cunningsoft/message-bundle": "0.1.*"
        }
    }
    
  2. Run composer update cunningsoft/message-bundle to install the new dependencies.

  3. Register the new bundle in your AppKernel.php:

    <?php
    // in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new Cunningsoft\MessageBundle\CunningsoftMessageBundle(),
        // ...
    );
    
  4. Let your user entity implement the Cunningsoft\MessageBundle\Entity\UserInterface:

    // Acme\ProjectBundle\Entity\User.php
    <?php
    
    namespace Acme\ProjectBundle\Entity;
    
    use Cunningsoft\MessageBundle\Entity\UserInterface as MessageUserInterface;
    
    class User implements MessageUserInterface
    {
        /**
         * @var int
         */
        protected $id;
    
        /**
         * @var string
         */
        protected $username;
    
        /**
         * @return int
         */
        public function getId()
        {
            return $this->id;
        }
    
        /**
         * @return string
         */
        public function getUsername()
        {
            return $this->username;
        }
        // ...
    
  5. Map the interface to your user entity in your config.yml:

    // app/config/config.yml
    // ...
    doctrine:
        orm:
            resolve_target_entities:
                Cunningsoft\MessageBundle\Entity\UserInterface: Acme\ProjectBundle\Entity\User
    
  6. Update your database schema:

    $ app/console doctrine:schema:update
    
  7. Import routes:

    // app/config/routing.yml
    // ...
    cunningsoft_message_bundle:
        resource: "@CunningsoftMessageBundle/Controller"
        type: annotation
    
  8. Link to the messages list:

    // src/Acme/ProjectBundle/Resources/views/Default/index.html.twig
    // ...
    <a href="{{ path('cunningsoft_message_list') }}">messages</a>
    // ...
    
  9. Create a child bundle to fetch users

    mkdir src/Acme/MessageBundle
    
    // src/Acme/MessageBundle/AcmeMessageBundle.php
    <?php
    
    namespace Acme\MessageBundle;
    
    use Symfony\Component\HttpKernel\Bundle\Bundle;
    
    class AcmeMessageBundle extends Bundle
    {
        public function getParent()
        {
            return 'CunningsoftMessageBundle';
        }
    }
    
    // src/Acme/MessageBundle/Controller/MessageController.php
    <?php
    
    namespace Acme\MessageBundle\Controller;
    
    use Cunningsoft\MessageBundle\Controller\MessageController as BaseController;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    
    /**
     * @Route("/message")
     */
    class MessageController extends BaseController
    {
        public function findUser($id)
        {
            return $this->get('doctrine.orm.entity_manager')->getRepository('AcmeProjectBundle:User')->find($id);
        }
    
        public function findAllUsers()
        {
            return $this->get('doctrine.orm.entity_manager')->getRepository('AcmeProjectBundle:User')->findAll();
        }
    }
    

Changelog

  • 0.1 (master) First working version.
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.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky