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

Symfony Rpc Bundle Laravel Package

seven/symfony-rpc-bundle

A Symfony bundle for integrating RPC services into your application, making it easy to expose and handle remote procedure calls with framework-native configuration and service integration.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install and register. This is a Symfony 2-era bundle (~2.3–2.7), so you almost certainly need "seven/symfony-rpc-bundle": "~1.0" alongside a pinned symfony/symfony in the 2.x line. Register it in app/AppKernel.php:

    new Seven\Bundle\RpcBundle\SevenRpcBundle(),
    
  2. Expose the endpoint. Import the bundle routing so the XML-RPC server is reachable at the configured path (typically /rpc):

    # app/config/routing.yml
    seven_rpc:
        resource: "@SevenRpcBundle/Resources/config/routing.yml"
        prefix:   /rpc
    
  3. Look here first, in this order:

    • Resources/config/routing.yml – the actual endpoint path and controller.
    • DependencyInjection/Configuration.php – the full seven_rpc: config tree; this is the source of truth for every knob.
    • Resources/config/services.xml – the service tag name the bundle uses to discover your methods. Everything else depends on getting this right.
    • README.md + Tests/ – the only realistic documentation for a 25-star 2014 bundle.
  4. First use case: prove the transport, then ship a real method. Boot with a trivial system.echo / system.ping method so you can verify wiring with a raw XML request before mixing in domain logic:

    curl -s -X POST http://localhost/app_dev.php/rpc \
      -H 'Content-Type: text/xml' \
      --data '<?xml version="1.0"?>
    <methodCall><methodName>system.ping</methodName><params/></methodCall>'
    

    Once that returns a well-formed <methodResponse>, register one real service (e.g. OrderRpcMethods) and iterate.

Implementation Patterns

One service per method group. Group methods by aggregate (OrderRpcMethods, CustomerRpcMethods), not by client. Tag each service with the bundle's RPC method tag, then let the container inject repositories/services as usual — the XML-RPC layer should be a thin adapter over normal Symfony services.

class OrderRpcMethods
{
    public function __construct(private OrderRepository $orders) {}

    // Becomes the XML-RPC method "order.get"
    public function get($id)
    {
        $order = $this->orders->find((int) $id);
        if (!$order) {
            throw new RpcFaultException(404, 'Order not found');
        }

        return [
            'id'     => $order->getId(),
            'total'  => (float) $order->getTotal(),
            'status' => $order->getStatus(),
            'created'=> $order->getCreatedAt(), // DateTime => dateTime.iso8601
        ];
    }
}

Map XML-RPC types explicitly. The value marshaller only understands scalars, associative arrays (struct), sequential arrays (array), DateTime (dateTime.iso8601), and base64 strings. Cast at the boundary ((int), (float), (bool)) instead of trusting what the caller sends — XML-RPC clients happily send "5" where you wanted 5.

Faults vs. return values. A method that returns ['error' => ...] looks like success to the client. Throw a dedicated exception that the bundle converts into a <fault> with faultCode/faultString; reserve return-value error envelopes for clients that explicitly expect them.

Auth belongs in Symfony, not in every method. XML-RPC is stateless per call, so options are: HTTP Basic via the security firewall on the /rpc pattern, or credentials as the first two params of every call (the legacy convention many ERP clients use). Pick one and enforce it in a kernel request listener or a shared base class — never copy-paste credential checks into 30 methods.

Testing pattern. Two levels, both cheap:

  • Unit: call the method service directly with fixture data — the RPC layer contributes nothing here.
  • Functional: $client->request('POST', '/rpc', [], [], ['CONTENT_TYPE' => 'text/xml'], $xml) and assert on the response body. Keep a few golden XML fixtures (request_get.xml, response_get.xml) checked in; they double as documentation for external integrators.

Integration tip. The main reason to reach for this bundle is that you already have an XML-RPC client to satisfy (Odoo, WHMCS, a legacy desktop app, Moodle). Write the client's expected request XML first, then implement the method against it — don't design the API surface and hope the client adapts.

Gotchas and Tips

  • It is effectively abandoned (last release Oct 2014). 0 dependents on Packagist, so expect zero upstream fixes. Before committing, verify it installs and boots on your exact PHP/Symfony pair; the underlying XML-RPC library may use removed PHP functions (each(), old preg_replace /e, mcrypt). If you're on PHP 8 or Symfony 4+, budget for a fork or just wire phpxmlrpc/phpxmlrpc yourself — the bundle is thin glue and often not worth the fight.
  • Trailing-slash and method routing are easy to break. The server typically dispatches on methodName inside a single controller action. If system.listMethods works but your method 404s/faults, the problem is almost always the service tag or the method name mapping, not routing.
  • null is not an XML-RPC type. Returning null from a method produces an empty/invalid value or a marshalling error depending on the lib version. Always return something concrete.
  • Struct keys must be strings. ['0' => 'a', '1' => 'b'] may serialize as an array instead of a struct; use named keys for structs and array_values() for arrays.
  • POST + text/xml only. Proxies, WAFs, and some reverse proxies will strip or block this content type. If calls fail only in staging, check the proxy before the code.
  • Debugging recipe: log the raw request body in a kernel listener (before the bundle's controller runs), and use curl --data @request.xml rather than a hand-typed one-liner. Most "it doesn't work" reports are malformed XML, not server bugs. Turn on the XML-RPC library's debug output via the bundle config if exposed.
  • Extension points are service overrides. The method resolver and type converter are container services — override the definition in your app's services.yml rather than subclassing the bundle. That's the only way to add custom types or change fault formatting without patching vendor/.
  • Never expose write methods unauthenticated. There's no CSRF story here and the endpoint is a single URL; anything reachable is reachable by anyone who can POST.
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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels