草庐IT

Silex-WebProfiler

全部标签

php - 如何在 Silex-WebProfiler 中集成 Monolog?

我目前正在使用带有Monolog的Silex框架作为日志记录机制。通过使用以下组件,我能够在我的项目中成功集成默认的SymfonyWebProfiler-https://github.com/silexphp/Silex-WebProfiler(Silex-WebProfiler)。它可以工作,但遗憾的是它无法从其_profiler页面显示来自Monolog的日志消息。有人知道如何解决这个问题吗?如果相关的话,这是我的配置:useSilex\Provider;...//Monolog$app->register(newProvider\MonologServiceProvider(),

php - 在 Controller 中找不到接口(interface) 'Silex\ControllerProviderInterface'

执行api.php时:Fatalerror:Interface'Silex\ControllerProviderInterface'notfoundinC:\xampp\htdocs\lab\src\Api\UserController.phponline9Composer:{"require":{"silex/silex":"^2.0"},"autoload":{"psr-4":{"Api\\":"src/Api"}}}api.php:mount('/',newApi\UserController());$app->run();src/Api/UserController.php:g

php - 在 Silex 中检测环境类型(生产、开发或暂存)

我正在使用微型框架Silex,我需要在运行时检测给定脚本内的环境类型。这意味着,检测它是dev、prod还是staging。 最佳答案 我没有使用Silex的经验,但我总是为此使用环境变量。然后在您的应用程序中,您可以通过以下方式获取当前环境:getenv('ENVIRONMENT') 关于php-在Silex中检测环境类型(生产、开发或暂存),我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/ques

php - 使用 Silex 将文件作为下载提供

我的Controller是基本的$app->get('/files/{type}',function($type)use($app){$path=__DIR__."/../files/$type";if(!file_exists($path)){$app->abort(404,"Cefichiern'existepas.");}return$app->sendFile($path);})->bind('getfile');根据这个doc有用。当我调用正确的URL时,文件会在当前窗口中打开。但是我不想在浏览器中打开文件,我想打开对话框只保存文件。我该怎么做?

php - 无法在 Silex 应用程序中找到 Controller

早上好过去几周我一直在使用Silex开发一个应用程序,昨晚我更改了我的代码,或者作为更新composer的一部分更新了一些东西,但它不起作用。我正在使用“Igorw\ConfigServiceProvider”来加载链接到我配置的Controller的路由。但是当我访问该网页时,我收到错误消息:InvalidArgumentException:Unabletofindcontroller"controllers.admin:index".我的文件如下composer.json{"require":{"silex/silex":"1.2.*@dev","igorw/config-serv

php - silex 如何使路由结束 "/"可选

我正在使用Silex1.1和PHP5.3,如何在路由中将结尾“/”设为可选?目前我有两条路线在做同样的事情$app->get('/item/{id}/',function($id)use($app){/**CodesHere**/});$app->get('/item/{id}',function($id)use($app){/**CodesHere**/});是否可以在结尾“/”可选的情况下仅指定一次路由?以及如何?谢谢 最佳答案 如果您使用尾部斜杠定义路由,则任何没有尾部斜杠的请求都会将301重定向返回到正确的请求。所以定义/i

php - Silex 路由问题(除 root 之外的其他路径提供 404)

这看起来应该可行,但我收到404错误。我的应用看起来像这样:lib/init.php:$app=newSilex\Application();$app->register(newSilex\Provider\TwigServiceProvider(),array('twig.path'=>__DIR__.'/../views',));$app->register(newSilex\Provider\UrlGeneratorServiceProvider());和web/index.php:require_once__DIR__.'/../lib/init.php';$app->get(

php - Silex 上的绑定(bind)方法

我到处都找不到它。那么请问:在silex上,我们为什么要使用bind()呢?例如,在这个静态页面的路由上:$pages=array('/'=>'index','/blog'=>'blog','/about'=>'about',);foreach($pagesas$route=>$view){$api->get($route,function(Silex\Application$app)use($view){return$app['twig']->render($view.'.html');})->bind($view);} 最佳答案

php - Silex v1.3 到 Silex v2 : Twig_Error_Runtime

我最近将一切正常的Silexv1.3项目迁移到了Silexv2。我收到一个Twig错误,我不明白原因Twig_Error_RuntimeinTemplate.phpline590:Neithertheproperty"request"noroneofthemethods"request()","getrequest()"/"isrequest()"or"__call()"existandhavepublicaccessinclass"Silex\Application"in"index.twig"atline5这是我的index.twig文件的前5行{%extends"layout.t

php - 使用 Symfony3 组件时,Silex FormServiceProvider 无法加载类型 "form"

尝试构建表单时收到此错误:InvalidArgumentExceptioninFormRegistry.phpline87:Couldnotloadtype"form"我已经注册了FormServiceProvider、TranslationServicerProvider和ValidatorServiceProvider。这是我的代码的相关部分:$this->_form=$this->_app['form.factory']->createBuilder('form',$this->_map())->add('firstName','text',['constraints'=>[ne