Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 1324

Extension Writers Discussion • Creating a controller that handles POST

$
0
0
I have:

routing.yml

Code:

tig_blobuploader_blobuploader:    path: /blobuploader    defaults: { _controller: tig.blobuploader.controller.blobuploader::handle_request }    methods: [POST]
services.yml

Code:

services:...    tig.blobuploader.controller.blobuploader:        class: tig\blobuploader\controller\blobuploader        arguments:            - '@user'            - '@request'            - '%core.root_path%'            - '%core.php_ext%'
blobuploader.php

Code:

<?phpnamespace tig\blobuploader\controller;use Symfony\Component\HttpFoundation\Response;class blobuploader{    protected $user;    protected $request;    protected $root_path;    protected $php_ext;    public function __construct(        user $user,        request $request,        $root_path,        $php_ext    ) {        $this->user = $user;        $this->request = $request;        $this->root_path = $root_path;        $this->php_ext = $php_ext;    }    public function handle_request ()    {        ...     }
When I do curl -X POST -F "image=@images/spacer.gif" http://localhost/blobuploader

I get

Code:

<br /><b>Fatal error</b>:  Uncaught TypeError: Symfony\Component\HttpKernel\Event\FilterControllerEvent::__construct(): Argument #2 ($controller) must be of type callable, array given, called in /var/www/html/phpbb/vendor/symfony/http-kernel/HttpKernel.php on line 138 and defined in /var/www/html/phpbb/vendor/symfony/http-kernel/Event/FilterControllerEvent.php:32Stack trace:#0 /var/www/html/phpbb/vendor/symfony/http-kernel/HttpKernel.php(138): Symfony\Component\HttpKernel\Event\FilterControllerEvent-&gt;__construct()#1 /var/www/html/phpbb/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw()#2 /var/www/html/phpbb/app.php(35): Symfony\Component\HttpKernel\HttpKernel-&gt;handle()#3 {main}  thrown in <b>/var/www/html/phpbb/vendor/symfony/http-kernel/Event/FilterControllerEvent.php</b> on line <b>32</b><br />  
I've searched and searched for examples of POST controllers and haven't found one.

Help, please!

Statistics: Posted by tig_ — Fri Jan 10, 2025 7:03 pm



Viewing all articles
Browse latest Browse all 1324

Trending Articles