duan47676379 2014-10-17 11:44
浏览 35

Laravel过滤器未执行

I have a very weird problem.

On my local machine (Windows 8, XAMPP) the Laravel filters work as they should, but on the server they don't. (Ubuntu with Apache).

Route::filter('test_filter', function($request) {
    echo 'Inside filter<br />';
});

Route::get('test_server2', array('before' => 'test_filter', function() {
    return 'After filter<br />';
}));

When I run this from my local server, the output is:

Inside filter
After filter

When I run the same script from the web, I get:

After filter

As you can see, the filter is not being applied. They are never executed. It's not a random or temporary thing.

I noticed this problem in a large application that I have. I created this simple code to check if the basic stuff works, but it doesn't.

Does anyone know why filters may not be executed?

I've checked the routing classes in the source code of Laravel and I haven't found anything that might help to solve my issue.

  • 写回答

3条回答 默认 最新

  • dongpai2468 2014-10-17 12:50
    关注

    First: always define what specific version of Laravel you are using, and where everything is executed.

    Some code is executed on production only. If you defined your filter in app/start/artisan.php or app/start/local.php it will not reflect when you execute your application on a server with environment set to production. We are unable to help if you do not exactly specify where your lines of code are defined.

    Last but not least: try to reduce the differences between your development environment and your production environment. I recommend using Vagrant and possibly even Laravel Homestead. That way you can develop Laravel applications on Windows and run in a virtual Ubuntu environment.

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 html5+css有人可以帮吗?
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?