草庐IT

event-routing

全部标签

php - 拉维尔 5.2 : Creating a custom route function - extending route

基本上,我想创建自己的Route::custom函数。这是因为我一直在为整个站点的多个路由使用相同的组和中间件(我还使用带有子域的模块,所以我们正在谈论为每个路由节省5-6行代码)我只想让Route::custom调用两个或三个其他Route函数。例如:Route::Module('forum')替换为Route::group(['middleware'=>['web','auth'],'domain'=>'forum.'.env('SITE_DOMAIN','example.com')],function(){Route::group(['middleware'=>'permissi

php - 仅在 Laravel Events 中返回时间戳

当我监听一个事件时,laravel返回的时间戳格式如下:created_at:{date:"2018-03-0405:24:25.000000",timezone:"UTC"timezone_type:3}我怎样才能只在laravel事件中返回时间戳或像这样:2018-03-0405:24:25.000000 最佳答案 只需这样做:$dateTime=$object->created_at->toDateTimeString();或createanaccessor在您使用的模型中:publicfunctiongetCreatedAt

php - Zend 框架 : Removing default routes

我正在使用ZendFW1.9.2,想禁用默认路由并提供我自己的路由。我真的不喜欢默认的/:controller/:action路由。这个想法是在初始化时注入(inject)路由,当请求不能路由到注入(inject)的路由之一时,它应该被转发到错误Controller。(通过使用默认注册的Zend_Controller_Plugin_ErrorHandler)一切正常,直到我使用$router->removeDefaultRoutes();禁用了默认路由;当我这样做时,错误Controller不再将未路由的请求路由到错误Controller。相反,它将所有未路由的请求路由到默认Contr

php artisan route::list 给我一个错误:试图获取非对象的属性

当我输入时phpartisanroute:list我明白了Tryingtogetpropertyofnon-object当我输入时phpartisanroute:list-v我明白了Exceptiontrace:()at/home/vagrant/Code/app/CategorySettings.php:31Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()at/home/vagrant/Code/app/CategorySettings.php:31App\CategorySettings->getDefa

php - 在哪里放置 FB.Event.subscribe

下面是我在我的网站上用于FacebookLike按钮(和Share按钮)的代码。效果很好。我单击“赞”按钮,然后砰的一声,我的Facebook帐户的个人资料页面上出现了一个很好的通知。Facebook甚至会自动生成预览图像,而该图像恰好是我网站的Logo。精彩的。我网站上的Like计数器总计正确。所以我想记录点赞按钮的点击次数。根据this页面,代码FB.Event.subscribe('edge.create',function(response){});允许您执行此操作。在下面的代码中,我应该把代码放在什么地方FB.Event.subscribe('edge.create',fun

php - 我可以向 Laravel 中的 Route::group 添加参数,但在分派(dispatch)到 Laravel 中的路由之前将其删除吗?

我正在使用Laravel4创建由每个客户的accountname命名空间的API。每个客户都有自己的相同数据库。所以Foocorp应该进行如下所示的api调用:http://api.example.com/Foocorp/users/5Barcorpapi调用如下所示http://api.example.com/Barcorp/users/5出于业务/品牌原因,我必须在URL中包含帐户名称,因此我无法从URL路由中删除此参数。这是我用来尝试从路由中提取帐户名称、验证它是否处于事件状态并指向他们的数据库的过滤器。我希望删除accountname参数,这样我就可以编写我所有的Control

php - Laravel 4 重定向:: Action () "Route not defined"

我目前在使用Laravel4时遇到问题。我想将slugs用于论坛类别和论坛主题(slugs是独一无二的)。为了确定用户是在一个类别中还是在一个主题中,我有这条路线:Route::get('forum/{slug}',function($slug){$category=ForumCategory::where('slug','=',$slug)->first();if(!is_null($category))returnRedirect::action('ForumCategoryController@findBySlug',array('slug'=>$slug));else{$top

php - 拉维尔 : is it possible to set a controller dynamically for a route?

那么,假设我有一个简单的Controller来处理书籍。App\Http\Controllers\SimpleBooksController在routes.php中,我为它注册了一个路由:Route::get('books/{id}','SimpleBooksController@doSimpleStuff');但是书的世界并没有那么简单。所以我想要另一个Controller来处理真正复杂的书籍内容。在我的脑海里,我想象这样的东西会非常有用:classComplexBooksControllerextendsSimpleBooksController以便子类未明确处理的路由回退到父类。

php - 错误 : No route found for "GET/app/example"

我刚刚使用SymfonyInstaller在我的Windows10笔记本电脑上创建了一个Symfony应用程序.然后,我开始了:phpapp/consoleserver:run然后,我打开了http://localhost:8000/app/example如文档中所述,但我收到以下错误消息:ERROR-UncaughtPHPExceptionSymfony\Component\HttpKernel\Exception\NotFoundHttpException:"Noroutefoundfor"GET/app/example""atC:\Users\JVerstry\morepath\

php - Symfony2 "Parameter ""for route ""must match "[^/]++"(""given) to generate a corresponding URL."

我有这个路线文件:indexRechercheZones:path:/gestionzonestechniquesdefaults:{_controller:MySpaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique}requirements:methods: GETmodifierZones:path:/gestionzonestechniques/modifier/{nom}defaults:{_controller:MySpaceGestionEquipementsTec