Weave 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

Rest Bundle Laravel Package

silpo-tech/rest-bundle

REST Bundle from Silpo Tech provides a foundation for building RESTful APIs in PHP applications, with conventions and utilities to streamline request handling, serialization, and responses. It aims to reduce boilerplate for common API tasks.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install via Composer
    composer require silpo-tech/rest-bundle
    Since the package has no stable release history (last release 2025‑10‑03, 0 stars), pin a specific commit or version in composer.json to avoid surprises.

  2. Enable the bundle
    Add it to config/bundles.php if Symfony Flex doesn’t do it automatically:

    return [
        // ...
        SilpoTech\RestBundle\SilpoTechRestBundle::class => ['all' => true],
    ];
    
  3. Look first at the source and tests
    The README is likely minimal (0 dependents, no stars). Open src/ and tests/ in the repository to understand the public API. Search for service definitions in config/services.yaml and any attributes/annotations the bundle exposes (e.g., #[Rest], #[ApiResource], or route decorators). The tests are the most reliable usage examples.

  4. First use case
    A typical first step is to create a controller that returns JSON and let the bundle handle serialization, error responses, or content negotiation. For example, if the bundle provides a base controller or a response factory:

    use SilpoTech\RestBundle\Controller\AbstractRestController;
    
    class ProductController extends AbstractRestController
    {
        #[Route('/api/products', methods: ['GET'])]
        public function list(): Response
        {
            return $this->json(['items' => []]);
        }
    }
    

    Check the bundle’s Controller directory for available base classes or traits. If it offers attributes for automatic request mapping, apply them to a DTO and test with a simple GET endpoint.

Implementation Patterns

  • Controller organisation
    Use the bundle’s base controller (if provided) to standardise JSON responses, error handling, and HTTP status codes. Keep controllers thin: delegate business logic to services and let the bundle’s normalizers/event listeners handle serialisation and validation.

  • Serialisation and validation
    Integrate with Symfony’s Serializer and Validator. The bundle likely registers normalizers or listeners that automatically convert exceptions to JSON problem responses. Use Symfony’s #[Serialize] groups or the bundle’s own attributes to control output. For input, combine with #[MapRequestPayload] (Symfony 6.3+) or the bundle’s request‑to‑DTO mapping if available.

  • Error handling workflow
    Throw domain exceptions and let the bundle’s exception listener format them. If the bundle doesn’t provide one, register your own kernel.exception listener that returns a consistent JSON error shape. Check the bundle’s EventListener folder for existing behaviour.

  • CRUD example
    A typical day‑to‑day pattern:

    1. Define a DTO with validation constraints.
    2. Use a controller action that accepts the DTO (via #[MapRequestPayload] or manual deserialize).
    3. Call a service, return a JsonResponse or use the bundle’s response helper.
    4. Rely on the bundle’s exception handling to convert validation failures into 422 responses.
  • Integration tips

    • Register the bundle’s services only in config/services.yaml if they aren’t auto‑loaded.
    • Use Symfony’s debug:container to discover services tagged by the bundle (e.g., silpo_tech.rest.normalizer).
    • Combine with nelmio/api-doc-bundle if the bundle doesn’t provide OpenAPI generation – you’ll need to annotate routes manually.
    • For versioning, use Symfony’s route prefixes or the bundle’s versioning attributes if documented.

Gotchas and Tips

  • Sparse documentation and low adoption
    With 0 stars and 0 dependents, expect little community support. Treat the source as the documentation and write your own integration tests early. Check the repository’s issue tracker and commit history for stability signals.

  • Configuration quirks
    The bundle may have a Configuration.php that defines a tree; run bin/console config:dump-reference silpo_tech_rest (adjust the alias) to see available options. If the alias isn’t obvious, search the bundle’s DependencyInjection folder.

  • Debugging
    Use the Symfony profiler’s “Request” panel to inspect the bundle’s event listeners. If responses are unexpectedly formatted, check the priority of the bundle’s normalizers/listeners versus your own. bin/console debug:event-dispatcher kernel.exception shows registered listeners.

  • Extension points
    Look for interfaces or tagged services (e.g., ResponseFactoryInterface, ExceptionNormalizerInterface). You can decorate or replace them via services.yaml:

    services:
        App\Rest\CustomResponseFactory:
            decorates: silpo_tech.rest.response_factory
    

    Confirm the service ID by inspecting the bundle’s services.yaml.

  • Version pinning and upgrades
    Since the last release is recent but the package is immature, avoid ^1.0 constraints. Use a specific commit hash in composer.json and review changes before updating. Write a smoke test that hits a simple endpoint to catch breaking changes.

  • When to consider alternatives
    If you need mature features (API Platform, FOSRestBundle, Symfony’s native #[MapRequestPayload]), evaluate whether this bundle adds enough value. For small internal APIs, Symfony’s built‑in tools plus a thin custom base controller may be simpler and better supported.

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.
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings