0

我在 laravel 中的文件管理器有问题我在 app/views/birthday.php 上有页面生日&当我键入“url/birthday”时我的过滤器功能就像在 filter.php 上没有查看它查看的页面这个异常有人可以帮我解决这个问题??

Route::filter('birthday', function()
{
if (date('d/m/y') == '12/12/84') {
return View::make('birthday');
}
 });


Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
open: /Applications/MAMP/htdocs/laravel/bootstrap/compiled.php
            $value = new Response($value);
        }
        return $value->prepare($request);
    }
    protected function handleRoutingException(\Exception $e)
    {
        if ($e instanceof ResourceNotFoundException) {
            throw new NotFoundHttpException($e->getMessage());
        } elseif ($e instanceof MethodNotAllowedException) {
            $allowed = $e->getAllowedMethods();
Server/Request Data
REDIRECT_STATUS 200
HTTP_HOST   localhost:8888
HTTP_CONNECTION keep-alive
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36
HTTP_ACCEPT_ENCODING    gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE    en-US,en;q=0.8
HTTP_COOKIE SESS6dfcda19c3e59ded8edffd06298e84cb=7irT1RlCywJRCI_ixmeWBHEaZyObLbEmipT_fVzbpyE; SQLiteManager_currentLangue=2; laravel_session=63f30bf581a59f6eb5b35e1d6cfb0144
PATH    /usr/bin:/bin:/usr/sbin:/sbin
SERVER_SIGNATURE    
SERVER_SOFTWARE Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8x DAV/2 PHP/5.4.10
SERVER_NAME localhost
SERVER_ADDR ::1
SERVER_PORT 8888
REMOTE_ADDR ::1
DOCUMENT_ROOT   /Applications/MAMP/htdocs
SERVER_ADMIN    you@example.com
SCRIPT_FILENAME /Applications/MAMP/htdocs/laravel/public/index.php
REMOTE_PORT 52931
REDIRECT_URL    /laravel/public/Birthday
GATEWAY_INTERFACE   CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD  GET
QUERY_STRING    
REQUEST_URI /laravel/public/Birthday
SCRIPT_NAME /laravel/public/index.php
PHP_SELF    /laravel/public/index.php
REQUEST_TIME_FLOAT  1374365008.97
REQUEST_TIME    1374365008
argv    Array ( )
argc    0
GET Data
empty
POST Data
empty
Files
empty
Cookies
SESS6dfcda19c3e59ded8edffd06298e84cb    7irT1RlCywJRCI_ixmeWBHEaZyObLbEmipT_fVzbpyE
SQLiteManager_currentLangue 2
laravel_session 63f30bf581a59f6eb5b35e1d6cfb0144
Session
_sf2_attributes Array ( [_token] => y8EoLfqlyp7BQ4lCMlmm2lXbmG94jrAHgkql4cCR [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) )
_sf2_flashes    Array ( )
_sf2_meta   Array ( [u] => 1374365008 [c] => 1374362823 [l] => 7200 )
Environment Variables
SHELL   /bin/bash
TMPDIR  /var/folders/5j/8x2jxt2929xcz3fzlg2rbz7h0000gn/T/
Apple_PubSub_Socket_Render  /tmp/launch-6NgxGx/Render
USER    abdallaelnajjar
COMMAND_MODE    unix2003
SSH_AUTH_SOCK   /tmp/launch-cY8ARh/Listeners
Apple_Ubiquity_Message  /tmp/launch-fM0Jef/Apple_Ubiquity_Message
__CF_USER_TEXT_ENCODING 0x1F5:0:0
PATH    /usr/bin:/bin:/usr/sbin:/sbin
PWD /
HOME    
SHLVL   2
DYLD_LIBRARY_PATH   /Applications/MAMP/Library/lib

_   /Applications/MAMP/Library/bin/httpd
Registered Handlers
0. Whoops\Handler\PrettyPageHandler
4

1 回答 1

0

此异常表明您正在访问的页面不存在。您所做的是定义了一个名为birthday. 你要做的就是把它附加到这样的路线上:

Route::get('/', array('before' => 'birthday', 'use' => 'HomeController@index');

birthday每当有人访问 home ( /) 路由时,这将执行过滤器。您实际上需要创建一条名为生日的路线。我会做的是如下所示:

Route::get('/birthday', array('before' => 'check', 'use' => 'BirthdayController@index');

然后在 中filters.php,添加以下内容:

Route::filter('check', function()
{
    if (date('d/m/y') == '12/12/84') {
        return View::make('birthday');
    }
});

根据您的命名约定等,此代码可能会有所不同,但您明白了。

于 2013-07-21T00:49:53.917 回答