Re: "Upgrade" to PHPSpreadsheet

Maybe this is old news and you folks have already got this figured out but does anyone find it odd that you need to go to such extreme archaic measure(DOS) to use something(PHPSpreadsheet) that is now dependent on “next level” (Composer) with an http proxy (on local PC) when it used to be in just a zipped directory (phpexcel) you could download into any project… Wow, talk about progress.

As I understand it (using DOS commands) once Composer has downloaded PHPSpreadsheet it will create a vendor/autoload.php directory/file that is then further used to access the program. You can then upload these created files to a host online.

I have made many sites over the years that use phpexcel to generate reports that now need to be reworked for php 8+ changes.

Anyone else dealing with this?

It looks like your problem is not PHPSpreadsheet itself but Composer that you don’t want to use? DOS is hardly archaic, it’s a command line in Windows used often by programmers. It’s as if you said command line is archaic on Linux. By being operated from the command like it is made multi-platform and also allows some automation if anyone wants. Composer is a very useful tool for downloading libraries. Maybe you will not appreciate it if you use it just for one library and for the first time - because every tool needs some learning, although it’s fairly simple.

autoload.php is used to include needed files automatically. It’s very useful because you don’t have to think about using require_once for every file, which you’d have to do otherwise. And it can even include your own files in you have classes organized in a standard directory structure.

Yes, the library will be downloaded to vendor directory, which then you can upload to the server.

Actually, PHPSpreadsheet is on github and you can download it from there and use it without Composer if you really must. It’s just a lot easier to use Composer (once you learn it).

I also used phpexcel and now PHPSpreadsheet, which I find much better overall.

I guess I would need to see some examples of how you use PHPSpreadsheet without Composer as I have downloaded PHPSpreadsheet, which doesn’t come with the “samples” directory and all samples I’ve seen thus far have require 'vendor/autoload.php';.

Most libraries depend on composer these days, so if you want to work in development, you really need to learn how to use it. Why composer? Several reasons

  1. It makes managing your required libraries easy. You just tell composer (via the composer.json file) which libraries and which version of them you need. Composer then handles downloading and installing everything for you automatically. It can also automatically upgrade them to the latest versions (if you permit it to).
  2. It handles auto-loading of a libraries (and optionally your own) classes. One of the biggest issues in the past was setting up proper include/require statements to make sure all required classes and functions were available in your code. Composer manages all this for you via that vendor/autoload.php file.
  3. It creates a common standardized ecosystem for libraries to use, making it much easier to both develop and use third-party libraries in your code.

You also should be comfortable using the command line as a developer. You speak about it like it’s some outdated technology but the command line is very much still used, especially for development / power user tools as it’s a lot easier to develop for compared to a GUI.

Taking a quick look at PHPSpreadsheet, it appears as though it’s only really intended to be used via composer. While you can download a zip of the source files, it’s going to rely on composer’s autoloading feature to load classes. If you want to avoid composer, you’d probably have to implement that yourself, which would likely be more effort than just learning and setting up composer.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.