PHP Project Composer自动加载无法找到类

时间:2016-10-30 18:35:33

标签: class composer-php autoload psr-4

我正在建立一个身份验证系统,我使用Composer来管理依赖关系。 当我运行我的项目时,似乎找不到任何类。我使用cmd生成了文件。我找到了类似的帖子herehere,但它并没有这么做......有什么想法吗?

错误

  

致命错误:Class' Bixxcom \ User \ User'找不到   第34行的C:\ xampp \ htdocs \ authentication \ app \ start.php

start.php

<?php
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
use Bixxcom\User\User;
use Bixxcom\Helpers\Hash;

session_cache_limiter(false);
session_start();

ini_set('display_errors', 'On');

define('INC_ROOT', dirname(__DIR__));

require INC_ROOT . '/vendor/autoload.php';

$app = new Slim([
    'mode' => file_get_contents(INC_ROOT . '/mode.php'),
    'view' => new Twig(),
      'templates.path' => INC_ROOT . '/app/views'
]);

$app->configureMode($app->config('mode'), function() use ($app){

    $app->config = Config::load(INC_ROOT .  "/app/config/{$app->mode}.php");

        });

        require 'database.php';
          require 'routes.php';

        $app->container->set('user', function(){
            return new User;
        }  );

                $app->container->singleton('hash', function() use ($app){
                    return new Hash ($app->config);
        });


        $view = $app->view();
        $view->parserOptions = [
            'debug'  => $app->config->get('twig.debug')
   ];

           $view->parserExtensions = [
               new TwigExtension
           ];

composer.json

{

    "autoload":{
        "psr-4":{
            "Bixxcom\\":  "app/Bixxcom"
        }
    },


    "require": {
        "monolog/monolog": "1.0.*",
        "slim/slim": "~2.0",
        "slim/views": "0.1.*",
        "twig/twig": "~1.0",
        "phpmailer/phpmailer": "~5.2",
        "hassankhan/config": "0.8.*",
        "illuminate/database": "~5.0",
        "ircmaxell/random-lib": "~1.1"
    }
}

user.php的

<?php
namespace Bixxcom\User;

 use Illuminate\Database\Eloquent\Model as Eloquent;

 class User extends Eloquent
 {
     protected $table = 'users';

     protected $fillable = [
             'username',
             'password',
             'active',
             'active_hash',
             'recover_hash',
             'remember_user',
             'remember_token',
             'first_name',
             'last_name',
             'age',
             'email',
             'phone',
             'address',
             'city',
            'country'
     ];
 }

enter image description here

0 个答案:

没有答案