-
-
Notifications
You must be signed in to change notification settings - Fork 205
CakePHP Integration
Ankit Pokhrel edited this page Nov 23, 2020
·
6 revisions
-
Add
ankitpokhrel/tus-php
as your dependency.$ composer require ankitpokhrel/tus-php
-
Create a controller, say
TusController.php
or you can also use existing controller.<?php namespace App\Controller; use Cake\Controller\Controller; use TusPhp\Tus\Server as TusServer; use Symfony\Component\HttpFoundation\Response as HttpResponse; class TusController extends Controller { /** * Create tus server. * * @return HttpResponse */ public function server() { $server = new TusServer('redis'); $server ->setApiPath('/tus') // tus server endpoint. ->setUploadDir(WWW_ROOT . 'uploads'); // uploads dir, make sure it exists and is accessible. return $server->serve(); } }
-
Add a route to serve the request.
// config/routes.php $routes->connect('/tus/*', ['controller' => 'Tus', 'action' => 'server']);
You can now access tus server endpoints at
http://yourapp.dev/tus
orhttp://yourapp.dev/tus/
.