32
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fuelphp1.7.2をzipで入れた場合にcomposer使うとfuelが動かなくなる

Posted at

fuelphp1.7.2のzipを解凍して設置すると正常に動作しますが、
この状態でcomposerを使うとfuelが動かなくなるので注意。

php composer.phar install

とかを実行すると以下のエラーになる

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files

Fatal error: Class 'Monolog\Logger' not found in /path/to/fuel/core/classes/log.php on line 100

Fatal error: Class 'Monolog\Logger' not found in /path/to/fuel/core/classes/log.php on line 100
Script php oil r install handling the post-install-cmd event returned with an error
                      
  [RuntimeException]  
  Error Output:       
                      

この状態になるとブラウザから接続した際も以下のエラーが出て動かない

Fatal error: Class 'Monolog\Logger' not found in /path/to/fuel/core/classes/log.php on line 100

恐らく1.7.2からの変更点としてfuel/coreなどのリポジトリをcomposerからインストールできるようになった変更が影響しているのだと思います。今の問題は、zipに含まれる fuel/vendor 以下のパッケージがcomposerで管理されていないのが原因。

以下の作業ですべてcomposerで管理するようにすれば解決した

fuel/vendor のディレクトリごと削除

fuel/vendorのディレクトリごと削除します。
少なくともfuel/vendor/composer は消さないと以下のエラーが出ます

[RuntimeException]                                                                                                                                    
  The .git directory is missing from /path/to/fuel/vendor/composer/installers, see http://getcomposer.org/commit-deps for more information   

composer.json の内容を編集

zipのcomposer.jsonにはmonolog等をインストールする記述がなくなってるので、1.7.2でzipに含まれていたパッケージをインストールするようにcomposer.jsonを修正します

composer.json
{
    "name": "fuel/fuel",
    "type": "project",
    "description" : "FuelPHP is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start!",
    "keywords": ["application", "website", "development", "framework", "PHP"],
    "license": "MIT",
    "require": {
        "php": ">=5.3.3",
        "composer/installers": "~1.0",
        "monolog/monolog": "1.5.*",
        "fuelphp/upload": "2.0.*",
        "michelf/php-markdown": "1.4.*"
    },
    "suggest": {
        "dwoo/dwoo" : "Allow Dwoo templating with the Parser package",
        "mustache/mustache": "Allow Mustache templating with the Parser package",
        "smarty/smarty": "Allow Smarty templating with the Parser package",
        "twig/twig": "Allow Twig templating with the Parser package",
        "pyrocms/lex": "Allow Lex templating with the Parser package",
        "mthaml/mthaml": "Allow Haml templating with Twig supports with the Parser package"
    },
    "config": {
        "vendor-dir": "fuel/vendor"
    },
    "scripts": {
        "post-install-cmd": [
            "php oil r install"
        ]
    },
    "minimum-stability": "dev"
}

具体的には

        "monolog/monolog": "1.5.*",
        "fuelphp/upload": "2.0.*",
        "michelf/php-markdown": "1.4.*"

を追加してます

Composerでパッケージインストール実行

php composer.phar self-update
php composer.phar update

これでブラウザから接続したら復旧してるはず。

32
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?