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

消息: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();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配