草庐IT

Silex-WebProfiler

全部标签

php - 使用 Silex/Symfony 传递响应后删除文件

我正在我的Silex应用程序中使用Knp\Snappy\Pdf生成pdf。文件名随机,保存到tmp目录下。$filename="/tmp/$random.pdf"$snappy->generate('/tmp/body.html',$filename,array(),true);我想在响应中返回pdf,$response=newResponse(file_get_contents($filename));$response->headers->set('Pragma','public');$response->headers->set('Content-Type','applicati

php - Silex 中的内部转发而不向浏览器发送 301/302

我正在使用Silex的内部转发将公共(public)URL映射到内部URL即my.domain.com/something实际上服务于my.domain.com/something_else使用$subRequest=Request::create($redirect,$method,[],//params$request->cookies->all(),$request->files->all(),$request->server->all());if($request->getSession()){$subRequest->setSession($request->getSessi

php - 如何对 Silex 应用程序进行故障排除?

我正在尝试做我认为是最基本的事情,但它花费了太多时间。我只是想让我的索引文件指向或转发到另一个文件。我最初是用一个简单的衬垫来做的。require_oncegetcwd()."/web/source/index.php";迁移到Silex后,我尝试了这个:$app->get('/',function($path)use($app){return$app->sendFile('/web/source/index.php');});但是没有去。当我访问我的网站时,我看到一个描述性很强的“哎呀,出了点问题”。我该如何解决这个问题?这是包含所有样板的完整代码:require_once__DIR

php - 在 Silex 中捕获 "Allowed memory size exhausted" fatal error

是否可以使用ErrorHandler/ExceptionHandler模块在Silex中捕获“允许的[n]字节的内存大小耗尽”fatalerror?一个简单的测试用例展示了如何轻松捕获其他类型的fatalerror-例如,以下将捕获PHPStringsizeoverflowfatalerror:useSymfony\Component\Debug\ErrorHandler;useSymfony\Component\Debug\ExceptionHandler;$errorHandler=function($e){error_log("Caughtanerror!");};ErrorHa

php - Silex 2 addListener 触发错误

我正在尝试将事件监听器/调度程序添加到我的Controller操作之一。它的目标是在将默认数据保存到我的数据库之前将其添加到我的实体。这是我到目前为止所得到的。app.php$app['dispatcher']->addListener('my_event_name',function(Event$event){//dosomething;});最终出现以下错误:(!)InvalidArgumentException:Identifier"dispatcher"doesnotcontainanobjectdefinition.in/var/www/site/vendor/pimple/

php - Silex + Swift Mailer 不工作

我有一个带有SwiftMailer的Silex应用程序,但似乎没有从$app['swiftmailer.options']加载配置。我在我的Bootstrap文件中注册了该服务$app->register(newSwiftmailerServiceProvider());在我的配置文件中$app['swiftmailer.options']=array('host'=>'smtp.mandrillapp.com','port'=>'587','username'=>'MY_USERNAME','password'=>'MY_PASSWORD','encryption'=>null,'a

php - Silex 路由 .htaccess webroot

我将Silex“微框架”用于我的应用程序的路由目的。我目前在研究如何使用.htaccess重写url。标准Silex网址:localhost/myapp/web/index.php/hello/name我希望它看起来像:localhost/myapp/hello/name使用以下.htaccess代码,我可以省略/index.php/部分。但我仍然必须使用/web/部分。RewriteEngineOnRewriteCond%{THE_REQUEST}/myapp/web/index.php/RewriteRule^/myapp/web/index.php/(.*)/myapp/$1[R

php - Silex 中的自定义 BaseController

我已经在Silex1.3.4中创建了一个简单的应用程序,我想要一个基本Controller,它有一个接受$app和$request的__construct方法。所有继承的Controller都应该有各自的构造函数并调用父Controller的构造方法。//Usestatementshere....classAppController{publicfunction__construct(Application$app,Request$request){$this->app=$app;$this->request=$request;}}继承Controller可以这样写://Usestat

php - 在 Silex 中定义日志记录

如果我在Silex中定义monolog日志:useMonolog\Logger;useMonolog\Handler\StreamHandler;useMonolog\Handler\FirePHPHandler;$app=newSilex\Application();$app->register(newSilex\Provider\MonologServiceProvider(),array('monolog.name'=>'logger','monolog.logfile'=>$logdir.'/f2alma.log','monolog.level'=>\Monolog\Logge

php - PHP 5.3.2 的 Silex 问题?

我尝试了Silex的示例并将我的Controller放在单独的目录和类中。默认情况下,Controller方法将获取Request和Application对象。这适用于我的开发机器,它有5.3.14,但不适用于默认的Ubuntu5.3.2。它给我:PHPCatchablefatalerror:Argument1passedtoSv\Controller\Index::index()mustbeaninstanceofSymfony\Component\HttpFoundation\Request,nonegiven,calledin/site/include/app/bootstrap