synergetic
synergetic

Reputation: 8036

Symfony 2, adding vendor library (PHPExcel etc.)

In my symfony 2.2 app I wanted to use PHPExcel library. So I downloaded it, and copied contents of Classes library to /vendor/phpexcel directory:

vendor/
    phpexcel/
        PHPExcel/
        PHPExcel.php

After that I added the following to app/autoload.php directly below $loader = require ... line:

$loader = require __DIR__.'/../vendor/autoload.php';

//The following was added
$loader->registerPrefixes(array(
    'PHPExcel' => __DIR__ . '/../vendor/phpexcel'
));

// intl
...

Now if I browse to my web app, it returns HTTP Error 500 (Internal Server Error). I read the following post, but wasn't able to solve the problem: How to use PHPExcel correctly with Symfony 2 Can someone help me correct this?

Upvotes: 0

Views: 5467

Answers (3)

synergetic
synergetic

Reputation: 8036

Composer seems to have a problem with SELinux. See this. Though not recommended, setting SELinux to permissive can be a workaraound.

Upvotes: 0

tigris
tigris

Reputation: 404

I installed https://github.com/liuggio/ExcelBundle for PHPExcel. Bundle includes PHPExcel (addes related links to composer). You can easily use PHPExcel without wondering what the bundle says. Call new \PHPExcel(); then you move. I hope this bundle helps.

Upvotes: 1

Gerry
Gerry

Reputation: 6012

You should never manually download something and put it in the vendor directory. Composer manages the vendor directory, and hence it should be save to delete this directory and run composer install again. The vendor directory also is excluded from Git by default.

To install PHPExcel using composer, add it to composer.json:

"require": {
    ...
    "phpexcel/phpexcel": "1.7.*"
}

When installed with Composer, you should not need to worry about the autoloading either.

Upvotes: 4

Related Questions