【问题标题】:Laravel 3.5 - View [Index] Not FoundLaravel 3.5 - 查看 [索引] 未找到
【发布时间】:2017-05-30 05:44:19
【问题描述】:

更新结束 - 问题已解决

问题是我的服务器没有正确设置,因为域没有正确连接到我的 VPS。联系了托管服务提供商,问题解决了。

如果有人遇到这个问题,请检查

  1. 您是否已经在使用php artisan config:cache 或php artisan config:clear?
  2. 您是否使用yourview.blade.php 正确命名了您的视图?
  3. 您是否在resources\views 中正确放置了视图?

我已经将 laravel 应用部署到我的 VPS 中。它在本地主机上运行良好。 错误信息如下所示:

InvalidArgumentException in FileViewFinder.php line 137:  
View [index] not found.  

1.  in FileViewFinder.php line 137
2.  at FileViewFinder->findInPaths('index', array('E:\Laravel\portofolio\resources\views')) in FileViewFinder.php line 79
3.  at FileViewFinder->find('index') in Factory.php line 174
4.  at Factory->make('index', array(), array()) in helpers.php line 856
5.  at view('index') in Portofolio.php line 56
6.  at Portofolio->link()
7.  at call_user_func_array(array(object(Portofolio), 'link'), array()) in Controller.php line 55

在错误信息的第 2 行,您可以看到它仍在本地目录中。我试过使用

php artisan config:clear|cache
php artisan view:clear
php artisan route:cache
php artisan optimize

甚至没有一个人解决了这个问题。这是php artisan config:cache 之后配置文件中的视图部分,您可以看到它已经在使用 VPS 目录

'view' => 
  array (
    'paths' => 
    array (
      0 => '/home/wahyuhan/portofolio/resources/views',
    ),
    'compiled' => '/home/wahyuhan/portofolio/storage/framework/views',
  ),

也许问题出在我的路由或控制器页面中,但我似乎无法在那里找到问题。服务器操作系统是 CentOS,我已经读到 CentOS 区分大小写但是我在这里没有看到任何区分大小写的问题。

这是我的服务器目录

Root
|-- portofolio
    |-- app
    |-- bootstrap
    |-- config
    |-- database
    |-- resources
        |-- assets
        |-- lang
        |-- views
            |-- index.blade.php
    |-- routes
    |-- storage
    |-- tests
    |-- vendor
|-- public_html
    |-- css
    |-- img
    |-- js
    |-- vendor

这是我的路线

Route::get('/', ['as' => 'home', 'uses' => 'Portofolio@link']);

这是我的控制器

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class Portofolio extends Controller
{
    public function link() {

        $categories = [
            '1' => 'Print Design',
            '2' => 'Logo Design',
            '3' => 'Web Design',
            '4' => 'Product Design',
            '5' => 'Character Design',
            '6' => 'Packaging Design'
        ];

        $projects = [
            '1' => 'IMSAA Training Certificate',
            '2' => 'Rusticity Logo',
            '3' => 'Handy Production Website',
            '4' => 'Nihon no Matsuri Bag Project',
            '5' => 'The Chin - Captain Jack Sparrow',
            '6' => 'Rusticity Packaging'
        ];

        $images = [
            '1' => '1',
            '2' => '2',
            '3' => '3',
            '4' => '4',
            '5' => '5',
            '6' => '6'
        ];

        $skills = [
            '1' => 'Photoshop',
            '2' => 'Ms. Office',
            '3' => 'Laravel',
            '4' => 'PHP',
            '5' => 'HTML',
            '6' => 'MySQL'
        ];

        $points = [
            '1' => '80%',
            '2' => '90%',
            '3' => '60%',
            '4' => '60%',
            '5' => '60%',
            '6' => '60%'
        ];

        return view('index')->withCategories($categories)->withProjects($projects)->withImages($images)->withSkills($skills)->withPoints($points);
    }
}

有什么建议吗?

【问题讨论】:

  • 尝试将索引刀片重命名为另一个。
  • @Rishi 我尝试将 index.blade.php 重命名为 home.blade.php 并执行 php artisan config:cache 但 奇怪的是错误还是一样view [index] not found
  • 运行这个命令php artisan cache:clear和php artisan view:clear
  • @Rishi 不工作,仍然有同样的问题

标签: php model-view-controller deployment routes laravel-5.3


【解决方案1】:

问题是我的服务器没有正确设置,因为域没有正确连接到我的 VPS。联系了托管服务商,问题解决了。

如果有人遇到这个问题,请检查

  1. 您是否已经在使用php artisan config:cache 或php artisan config:clear?
  2. 您是否使用yourview.blade.php 正确命名了您的视图?
  3. 您是否将视图正确放置在resources\views 中?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 2015-11-28
    • 1970-01-01
    • 2019-09-11
    • 2018-12-23
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多