dongtangu8615
2016-08-24 06:03
浏览 222
已采纳

消息:Codeigniter3.1中找不到类'Illuminate \ Database \ Capsule \ Manager'

I have try to configuration Codeigniter3.1 with Illuminate to use ORM but finally I got this errors as below.

An uncaught Exception was encountered

Type: Error

Message: Class 'Illuminate\Database\Capsule\Manager' not found

Filename: /Users/sopheak/Documents/web/com/application/config/database.php

Line Number: 10

This is My composer.json,

{
  "name": "illuminate/database",
  "description": "The Illuminate Database package.",
  "license": "MIT",
  "homepage": "https://laravel.com",
  "support": {
    "issues": "https://github.com/laravel/framework/issues",
    "source": "https://github.com/laravel/framework"
  },
  "keywords": ["laravel", "database", "sql", "orm"],
  "authors": [
    {
      "name": "Taylor Otwell",
      "email": "taylor@laravel.com"
    }
  ],
  "require": {
    "php": ">=5.6.4",
    "illuminate/container": "5.3.*",
    "illuminate/contracts": "5.3.*",
    "illuminate/contracts":"5.3.*",
    "nesbot/carbon": "~1.20",
    "codeigniter/framework": "3.1"
  },
  "autoload": {
    "classmap": [
      "application/core",
      "application/models",
      "application/libraries"
    ],
    "psr-4": {
      "Illuminate\\Database\\": ""
    }
  },
  "extra": {
    "branch-alias": {
      "dev-master": "5.4-dev"
    }
  },
  "suggest": {
    "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).",
    "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
    "illuminate/console": "Required to use the database commands (5.4.*).",
    "illuminate/events": "Required to use the observers with Eloquent (5.4.*).",
    "illuminate/filesystem": "Required to use the migrations (5.4.*).",
    "illuminate/pagination": "Required to paginate the result set (5.4.*).",
    "illuminate/queue": "Required to fire login / logout events (5.4.*).",
    "illuminate/session": "Required to use the session based guard (5.4.*).",
    "league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).",
    "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
    "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).",
    "illuminate/database": "Required to use the database cache driver (5.4.*).",
    "illuminate/redis": "Required to use the redis cache driver (5.4.*)."
  },
  "minimum-stability": "dev"
}

Configuration in Applications/Config/config.php

 $config['composer_autoload'] = true;

configuration on public/Index.php

 require_once  '../vendor/autoload.php';

Call Capsule in Application\Database\Capsule\Manager as Capsule.

use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;
$capsule->setAsGlobal();
$capsule->setAsGlobal();
$capsule->bootEloquent();
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doudi7782 2017-04-24 06:24
    已采纳

    After instantiating the

        $capsule = new Capsule;
    

    you have to add the connection:

        $capsule->addConnectio([
            'driver'    =>    'mysql',
            'host'      =>    'localhost',
            'database'  =>    'databaseName',
            'username'  =>    'username',
            'password'  =>    'password',
            'charset'   =>    'UTF8',
            'collation' =>    'utf8_unicode_ci',
            'prefix'    =>    ''
        ]);
    

    After adding the connection, you can go on to set it as global, then boot the eloquent:

        $capsule->setAsGlobal();
        $capsule->bootEloquent();
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题