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

Gedungbundle Laravel Package

ais/gedungbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation Add the package to your composer.json under require:

    "ais/gedungbundle": "dev-master"
    

    Run composer update to install dependencies.

  2. Register the Bundle In AppKernel.php, add the bundle to the $bundles array:

    new Ais\GedungBundle\AisGedungBundle(),
    

    Ensure dependencies (NelmioApiDocBundle, FOSRestBundle, JMSSerializerBundle) are also registered.

  3. Configure Routing Import the bundle’s routes in app/config/routing.yml:

    ais_gedungs:
      type: rest
      prefix: /api
      resource: "@AisGedungBundle/Resources/config/routes.yml"
    
  4. Access API Documentation Visit /api/doc (e.g., http://localhost/web/app_dev.php/api/doc) to explore the API endpoints via NelmioApiDoc.


First Use Case: CRUD for Gedung Entities

  • The bundle likely provides RESTful endpoints for managing "Gedung" (Indonesian for "building") entities.
  • Use POST /api/gedungs to create, GET /api/gedungs to list, and GET /api/gedungs/{id} to fetch a single entity.
  • Leverage FOSRestBundle for standardized JSON responses and JMSSerializerBundle for data transformation.

Implementation Patterns

Workflows

  1. Entity Management

    • Create: Send a JSON payload to /api/gedungs with required fields (e.g., name, address).
      curl -X POST -H "Content-Type: application/json" -d '{"name":"Gedung A", "address":"Jl. Raya 1"}' http://localhost/api/gedungs
      
    • Read: Fetch all or single records via GET /api/gedungs or GET /api/gedungs/{id}.
    • Update/Delete: Use PUT/PATCH or DELETE with the respective endpoint.
  2. Validation

    • The bundle likely uses Symfony’s validation component. Check for Validation errors in responses (HTTP 400).
  3. API Documentation

    • Use NelmioApiDoc to auto-generate Swagger/OpenAPI docs. Customize with @SWG\ annotations in controllers.

Integration Tips

  • Database Schema: The bundle includes Doctrine ORM entities. Extend or override them in AisGedungBundle/Resources/config/doctrine/ if needed.
  • Custom Controllers: Override default controllers by creating a GedungController in your app with @Route annotations.
  • Testing: Use LiipFunctionalTestBundle (dev dependency) for API tests. Example:
    $client = static::createClient();
    $client->request('GET', '/api/gedungs');
    $this->assertEquals(200, $client->getResponse()->getStatusCode());
    

Gotchas and Tips

Pitfalls

  1. Symfony Version Mismatch

    • The bundle targets Symfony 2.7.4. Avoid using with newer versions unless patched.
    • Conflicts may arise with FOSRestBundle@dev or NelmioApiDocBundle@dev. Pin versions in composer.json:
      "friendsofsymfony/rest-bundle": "~2.0",
      "nelmio/api-doc-bundle": "~2.12"
      
  2. Missing Dependencies

    • Ensure JMSSerializerBundle and FOSRestBundle are properly configured. Missing them breaks API serialization/routing.
  3. Route Overrides

    • If you override routes, ensure the new routing.yml extends the bundle’s routes:
      ais_gedungs:
        resource: "@AisGedungBundle/Resources/config/routes.yml"
        type: rest
        prefix: /api
      

Debugging

  • API Errors: Check Symfony’s profiler (/app_dev.php/_profiler) for detailed errors.
  • Database Issues: Verify Doctrine entities are mapped correctly. Run:
    php app/console doctrine:schema:validate
    
  • NelmioApiDoc: Clear cache if docs don’t update:
    php app/console cache:clear
    

Extension Points

  1. Custom Fields

    • Extend the Gedung entity by creating a subclass in your bundle:
      // src/Acme/MyBundle/Entity/GedungExtension.php
      namespace Acme\MyBundle\Entity;
      use Ais\GedungBundle\Entity\Gedung as BaseGedung;
      
      class GedungExtension extends BaseGedung {
          // Add custom properties/methods
      }
      
    • Update orm.xml or annotations to include the extension.
  2. Event Listeners

    • Subscribe to Doctrine lifecycle events (e.g., prePersist) to add logic:
      // src/Acme/MyBundle/EventListener/GedungListener.php
      namespace Acme\MyBundle\EventListener;
      use Doctrine\ORM\Event\LifecycleEventArgs;
      
      class GedungListener {
          public function prePersist(LifecycleEventArgs $args) {
              $gedung = $args->getEntity();
              // Add custom logic
          }
      }
      
    • Register in services.yml:
      services:
          acme.my_bundle.listener.gedung:
              class: Acme\MyBundle\EventListener\GedungListener
              tags:
                  - { name: doctrine.event_listener, event: prePersist }
      
  3. API Extensions

    • Add custom actions to the controller by extending the bundle’s GedungController:
      // src/Acme/MyBundle/Controller/GedungController.php
      namespace Acme\MyBundle\Controller;
      use Ais\GedungBundle\Controller\GedungController as BaseController;
      
      class GedungController extends BaseController {
          public function customAction() {
              return $this->handleView($this->get('gedung.manager')->customLogic());
          }
      }
      
    • Update routing.yml to include the new route.

Configuration Quirks

  • NelmioApiDoc: Customize the API doc URL or title in config.yml:
    nelmio_api_doc:
        areas:           # Use multiple areas
            path_patterns: [ ^/api ]
        documentation:
            info:
                title: "My Gedung API"
                description: "API for managing buildings"
    
  • FOSRest: Configure formats (JSON/XML) in config.yml:
    fos_rest:
        format_listener:
            rules:
                - { path: ^/api, priorities: [ json ], fallback_format: json }
    
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