There isn't a way for me to run composer on my server for a bunch of reasons. Is there any way to include all the files necessary to use the library?
-
7Possible duplicate of [How to use PhpSpreadsheet without installation (like PHPExcel)](https://stackoverflow.com/questions/48767355/how-to-use-phpspreadsheet-without-installation-like-phpexcel) – Pradeep Apr 20 '18 at 14:00
-
4you dont need to (and indeed you shouldn't). run composer locally, and just transfer the files to your server. – delboy1978uk Apr 20 '18 at 14:01
-
@delboy1978uk I did copy the phpspreadsheet files (the whole directory) to the server. Is there any way to load classes, without having to include one by one? – user187809 Apr 20 '18 at 14:08
-
4you either require every class (the way you just uploaded), just install composer locally, `composer require yourvendor/package`, `require_once 'vendor/autoload.php` in your script, and you can now autoload everything without requires. Just upload the composer.json, composer.lock, and vendor folders and you should be good to go. – delboy1978uk Apr 20 '18 at 14:22
4 Answers
I have phpspreadsheet
in (from the root html folder)
lib/php/phpspreadsheet
I just
require_once( 'lib/php/phpspreadsheet/autoload.php' );
then (since I am inside an already defined namespace) I create a spreadsheet with
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

- 15,233
- 27
- 70
- 91
@Lubosdz answered the question in the right way here:
How to use PhpSpreadsheet without installation (like PHPExcel)
Just coping files isn't enaugh to get it worked because composer is used to autoload all PhpSpreadSheet classes.
Without composer, you have to create your custom ones.
You can find a 4 steps method, files, and code here:
https://github.com/PHPOffice/PhpSpreadsheet/issues/31#issuecomment-354502740

- 5,031
- 17
- 33
- 41

- 110
- 1
- 5
-
Please include all relevant information here instead of linking to external pages – Nico Haase Jun 21 '19 at 07:46
07 2021
If any of you still looking for the solution. Then here it is.
How to run PhpSpreadsheet on a Server without Composer
See @delboy1978uk comment above
Run PhpSpreadsheet locally without Composer
Official:
Composer is the only official and supported solution to use PhpSpreadsheet. Alternative custom solutions are possible, but I'd strongly advise against them. Not using composer will give you more work to set up, and potential issues to maintain.
https://github.com/PHPOffice/PhpSpreadsheet/discussions/1969#discussioncomment-545159

- 7,911
- 4
- 41
- 40
As @delboy1978uk stated in the answer above:
- Run composer local on your machine,
- create the composer.json,
- require phpspreadsheet (https://packagist.org/packages/phpoffice/phpspreadsheet)
- composer update
- upload the complete /vendor Folder on your server, maybe as zip it is easier,
- include /vendor/autoload.php,
- there it is
And send a Sixpack of your favorite Beer to Mark Baker https://github.com/MarkBaker for his great work :-)

- 900
- 10
- 29