草庐IT

Level1Controller

全部标签

php - 将遗留应用程序移动到 Symfony2 : How to execute native php scripts in a controller?

我有一个遗留应用程序,我想将其移至Symfony2。这个应用程序不是用MVC构建的,它没有PSR-0兼容性,它在很大程度上是一个遗留应用程序,因为“/search.php”指向文件“search.php”并且包含菜单、页眉和页脚不同的文件共享。如果我能以某种方式将这个应用程序快速而肮脏地插入到Symfony2中,然后开始将它的一部分一次一个地移动到Symfony2应用程序架构中,那将是理想的。我真的不想做一些瀑布式的尝试来移植整个东西,然后在3-6个月内做一些大规模的更新。任何人都可以推荐一种方法来执行nativephp脚本,该脚本将在Symfony2Controller中包含诸如my

php - yii 中的 ajax 调用 Controller (javascript)

出于某种原因,这不起作用,我找不到让它起作用的方法!在我名为“ExplicacaoController”的Controller上,我有这个:publicfunctionaccessRules()...'actions'=>array('index','view','test','ajaxrequest'),...publicfunctionactionAjaxRequest(){$val1=$_POST['val1'];$val2=$_POST['val2'];echo"something";Yii::app()->end();}在我看来我有:...$.ajax({type:"POST

php - 嵌套资源 Controller laravel 4

在laravel4中我想要一个嵌套的Controller。我已阅读文档,但没有找到有关如何执行此操作的任何说明。假设在一个应用程序中我有一些文章,每篇文章都有自己的一组评论。我希望能够通过访问这样的URL来获取特定文章的所有评论。http://myapp.com/articles/5/comments我已经创建了一个commentsController,但我不知道如何从url中正确获取文章ID,所以我可以将它传递给我Controller中的所有CRUD方法 最佳答案 在route.php中Route::resource('artic

php - 扩展 Symfony2 Controller 解析器

我目前正在创建一个包,如果请求是Ajax请求,它可以将fooAction重命名为fooAjaxAction。作为thatquestion的答案说,我必须扩展Controller解析器类。如果我更改config.yml中的controller_resolver.class,我会遇到ResourceNotFoundException。但如果我不这样做,我就没有任何错误(但没有覆盖,所以这不是我想要的)我的问题是:如何注册我的新Controller解析器并使用它?我是对的?错了吗?这就是我所做的:您可以在packagist中找到我用于测试的Bundle并通过以下方式下载:composerre

php - Laravel 5 : Send a response first, 然后在 Controller 中处理请求

我正在使用ClassicPaypalAPI,但在处理请求数据之前遇到了响应问题。publicfunctionstore(){//SendanemptyHTTP200OKresponsetoacknowledgereceiptofthenotificationresponse("",200);//Buildtherequiredacknowledgementmessageoutofthenotificationjustreceived//Onceithitsthispoint,nothingissenttotheclient.}我知道为了让客户端收到HTTP200响应,我需要在它前面添加

php - Symfony2 : Get HTML from another file in controller

在我的Symfony2项目中,我想获取文件的HTML并将其放入Controller中的变量中。我有一个这样的Controller函数:publicfunctionmyControllerAction(){$htmlOtherFile='';return$this->render('@MyBundle/myTargetFile.html.twig',['htmlOtherFile'=>$htmlOtherFile]);}我想导入的html文件在我的View文件夹中:htmlOtherFile.html.twig如何将此文件的HTML放入我的$htmlOtherFile变量中?我已经尝试使

php - Symfony2 - 如何在 Controller 中使用@Entity 注释?

Symfony关于ParamConverter的手册有这个例子:/***@Route("/blog/{post_id}")*@Entity("post",expr="repository.find(post_id)")*/publicfunctionshowAction(Post$post){}来源:http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#fetch-via-an-expression但是使用@Entity注释给我这个错误。Theannot

php - 避免在 Controller 上使用 Laravel facade

我正在使用Laravel5.5并尝试通过psr-2standard来习惯编码(刚开始学习)。我用QuafooQA分析我所有的代码并逐步修复错误并记录下来。通过使用外观,我得到了这个错误“避免使用对类的静态访问”。因此,我尽量避免使用它们。在我的Controller上我有这段代码:make('LoadData/index');}//morecode}除了ViewFacade,我还使用了DB、Input、Validator和Storage这是正确的方法吗,还有其他方法吗? 最佳答案 您无需避免使用Facades-它们是框架的关键部分。但

php - 在 Yii2 Controller 中返回 json 的正确方法

我在网上寻找答案并与我的合作伙伴讨论过,但仍然不确定在yii2Controller中返回json的最佳选择。这里的选项:publicfunctionactionExample(){//1//dosomethingwhit$dataresult...\Yii::$app->response->format=\yii\web\Response::FORMAT_JSON;return$data;}publicfunctionactionExample(){//2//dosomethingwhit$dataresult...echojson_encode($data);Yii::$app->e

php - 无法在 Controller 中获取用户 ID 并且 Auth::check() 不工作 - Laravel 5.8

我是laravel5.8的新手,我无法在apiController中使用Auth,以下是详细信息:我已将默认用户表从users更改为UserUser.php'datetime',];}没有改变auth.php中的任何内容['guard'=>'web','passwords'=>'users',],'guards'=>['web'=>['driver'=>'session','provider'=>'users',],'api'=>['driver'=>'token','provider'=>'users','hash'=>false,],],'providers'=>['users'=