samdark / yii2-cookbook

Yii 2.0 Community Cookbook
1.45k stars 296 forks source link

The PDF can't be built #202

Open ghost opened 4 years ago

ghost commented 4 years ago

I tried to build the PDF of the book but got the following error:

vendor/bin/apidoc guide --template=pdf --interactive=0 ../book/ ./pdf PHP Fatal error: Cannot use 'Object' as class name as it is reserved in /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Object.php on line 77 PHP Stack trace: PHP 1. {main}() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2-apidoc/apidoc:0 PHP 2. require() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2-apidoc/apidoc:33 PHP 3. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/Yii.php:27 PHP 4. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/Yii.php:27 PHP 5. include() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/BaseYii.php:288 PHP 6. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/di/Container.php:98 PHP 7. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/di/Container.php:98 PHP 8. include() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/BaseYii.php:288 PHP 9. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Component.php:98 PHP 10. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Component.php:98

Fatal error: Cannot use 'Object' as class name as it is reserved in /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Object.php on line 77

Call Stack: 0.0002 359864 1. {main}() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2-apidoc/apidoc:0 0.0009 364416 2. require('/home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/Yii.php') /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2-apidoc/apidoc:33 0.0018 430872 3. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/Yii.php:27 0.0018 430920 4. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/Yii.php:27 0.0022 432328 5. include('/home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/di/Container.php') /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/BaseYii.php:288 0.0022 432328 6. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/di/Container.php:98 0.0022 432376 7. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/di/Container.php:98 0.0026 434376 8. include('/home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Component.php') /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/BaseYii.php:288 0.0026 434376 9. spl_autoload_call() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Component.php:98 0.0026 434416 10. yii\BaseYii::autoload() /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Component.php:98

make: *** [Makefile:6: book.pdf] Fehler 255

I just followed the steps of the provided readme.md file.

I am using Arch Linux and use the current version of php, composer and texlive in the repository.

samdark commented 4 years ago

Fatal error: Cannot use 'Object' as class name as it is reserved in /home/sebastian/Downloads/yii2-cookbook-master/build/vendor/yiisoft/yii2/base/Object.php on line 77

What version of Yii do you have?

ghost commented 4 years ago

I can't really tell from the composer.json file of the project, but the changelog of the yii package goes up to version 2.0.10, so i guess this is the installed version. Is there a better way to get the version of the installed Yii framework?

Edit: The composer.lock file says version 2.0.10 is installed.

samdark commented 4 years ago

You need at least 2.0.13 to use it with PHP 7.

ghost commented 4 years ago

I could get it to work, but there were some steps needed beforehand:

  1. Install the php-mcrypt extension as Yii2 needs it
  2. Update the composer.json to the following:
    {
    "require": {
        "yiisoft/yii2": "~2.0.35",
        "yiisoft/yii2-apidoc": "~2.1.0",
        "bower-asset/jquery": "~3.4.1"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
    }

    After that i can run make but i still get an error:

    vendor/bin/apidoc guide --template=pdf --interactive=0 ../book/ ./pdf
    Updating cross references and backlinks... done.
    Searching files to process... done.
    Rendering markdown files: 35% (17/48) ETA: n/a   Error: array_unique() expects parameter 1 to be array, null given
    make: *** [Makefile:6: book.pdf] Fehler 1

    I am using Arch Linux with PHP 7.4 by the way.