How to include phpspreadsheet library without composer?

Asked
Active3 hr before
Viewed126 times

2 Answers

withoutincludelibrary
90%

Currently I'm trying to find a way to read the uploaded spreadsheet file. ProcessWire doesn't seem to have modules suitable for my needs, but external PHP Library PhpSpreadsheet sounds like it could do the job. However, I can't even try it, because I simply don't understand how I can refer to an external library! , You don't need to include_once() if the vendor folder is in the ProcessWire installation root, it has loaded the libraries already, if i remember correctly the index.php of PW takes care of this. , I have tried different things varying from their documentation to forum posts and PW API with no luck. I would prefer not to use Composer, since it seems kind of overkill for one library. , Hi @iipa I am not familiar with PhpSpreadsheet, 🙄 but more generally speaking you can upload an external library calling a require_once() in profile ready.php or in site/config.php.

I load all my libraries from site/config.php calling a simple loader

/**
 * MRCMOD03: Add custom library Argo
 *
 */
include_once(__DIR__.
   '/includes/Argo.php');

which load all my functions and class libraries (same as PW does in wire/core/boot.php file)

< ? php namespace Argo;

$preloads = array(
   'argo/Functions.php',
   'argo/Object.php',
   'argo/Controller.php',
   'argo/Widget.php',
   'argo/WidgetTracker.php',
   'view/ContactForm.php',
   'view/CookieBanner.php',
   'view/FollowButtons.php',
   'view/RecentPosts.php',
   'view/ShareButtons.php',
   'view/LegalNotice.php',
   'controller/CookieController.php',
);

foreach($preloads as $file) {
   include_once(__DIR__.
      '/'.$file);
}

unset($preloads);

As library will have different namespace than Processwire namespace, do not forget to apply "use" directive before using a library class or function in your template 🤪

use\ Argo\ ShareButtons;
...
$sb = new ShareButtons();
load more v
88%

PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.,For more documentation in depth, you may read about an overview of the architecture, creating a spreadsheet, worksheets, accessing cells and reading and writing to files.,PHP version 7.3 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by composer. See the require section of the composer.json file for details., Welcome to PhpSpreadsheet's documentation Welcome to PhpSpreadsheet's documentation File formats supported Getting started Software requirements Installation Hello World Learn by example Learn by documentation Credits

Use composer to install PhpSpreadsheet into your project:

composer require phpoffice / phpspreadsheet
load more v

Other "without-include" queries related to "How to include phpspreadsheet library without composer?"