Reputation: 441
I would like to route php script from Vendor. I used Composer to instal database managment (https://github.com/vrana/adminer/). Source of that app is: vendor/vrana/adminer/adminer/index.php
I would like to create router to use this app, for example when I call url myweb.com/adminer, it should load that source: vendor/vrana/adminer/adminer/index.php
Is it possible to do it via routing.yml ? Something like this:
adminer:
resource: "Vendor/vrana/adminer/adminer/index.php"
prefix: /adminer
Or how it possible to do it?
Upvotes: 1
Views: 1069
Reputation: 539
It's really easy.
Create regular route and then include adminer.php and return it from controller. Do not forget to put this route under firewall
In controller:
use Symfony\Component\HttpFoundation\Response;
public function mysqlClientAction() {
return new Response(include_once $this->container->getParameter('kernel.root_dir') . '/Resources/views/adminer.php');
}
in routing.yml
admin_mysql_manager:
path: /mysqlclient
defaults: { _controller: YourBundle\Controller\YourController::mysqlClientAction}
Upvotes: 1
Reputation: 107
I solved something similar through template but I have czech version, only one file:
//app/Resources/views/adminer.html.php
<?php
include(__DIR__.'/../../../vendor/vrana/adminer/adminer/index.php');
?>
and route from Controler
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
/**
* @Route("/adminer", name="adminer")
* @Template(engine="php")
*/
public function adminerAction()
{
return $this->render('::adminers.html.php');
}
and put adminer.php and rename into /vendor/vrana/adminer/adminer/index.php Now address is yoursite/adminer
Upvotes: 0
Reputation: 1908
It is not possible via symfonys routing.yml
, since this needs the app kernel to be started, which is in app.php
. But you can just set up adminer as another server.
If you use apache for example write in /etc/apache2/sites-enabled/local
<VirtualHost *:80>
ServerName local.adminer
DocumentRoot /YourPathToAdminer
DirectoryIndex adminer.php
<Directory /YourPathToAdminer>
AllowOverride all
Allow from all
</Directory>
LogLevel debug
</VirtualHost>
And in your /etc/hosts
add somewhere
127.0.0.1 local.adminer
Just call http://local.adminer
in your browser and you are done.
Upvotes: 0