PHP 5.3: how to add PDFlib? - php

I recently upgraded my Linux server from Apache 2.1 to 2.4 and PHP 5.2 to 5.3. Previously I was using pdf.so from PDFlib fine, but when I tried to install it, as downloaded from here,
http://www.pdflib.com/download/free-software/pdflib-lite-7/
PHP failed to load the module as it was compiled in for PHP 5.3. This install was done using the newest version of PDFlib that I could find, 9.0.2.
Anyone know whether this is possible? I've already got things coded in PHP for PDFlib and prefer not to use another library unless the commands are the same.
UPDATE
Has anyone successfully used PDF Lite with PHP 5.3?

You must compile it. Currently no build is available for PHP 5.3.
On the Download-Site, READ the info:
PDFlib Lite source code must be compiled to generate a usable library. PDFlib GmbH does not offer precompiled (binary) versions of PDFlib Lite.
If you have compile errors, check out the error logs - What say it? Yep, i think you need additional sources for compiling (mostly).

Related

PHPSpreadsheet issue with PHP v5.5

This isn't particularly a coding question.
I have a script running locally (PHP V5.6) and it's absolutely perfect.
However, I FTPd it to our dev server to run as a cron and it failed. Our server has php v5.5 running for dependancy issues. Is there any way I can user composer require to install phpspreadsheet on a machine running PHP 5.5?
PHPSpreadsheet was deliberately written for PHP >=5.6.0 because I was fed up with the way people had made death threats to me for even suggesting that the minimum version of PHP required to run its predecessor (PHPExcel) should be increased from PHP 5.2 to take advantage of newer features of the language to reduce the codebase and memory footprint, and make it more performant
PHPSpreadsheet uses features of PHP that are only available in PHP 5.6 or above, and will soon drop support for even that version when Security support ends for that version of PHP on 31 Dec 2018, and require a minimum of PHP 7.1.0
If you need to create spreadsheets using older unsupported versions of PHP, then you can't use PHPSpreadsheet, and can only use its predecessor PHPExcel
No, PhpSperadsheet requires v5.6 or above.
In the docs # https://phpspreadsheet.readthedocs.io/en/develop/
Software requirements
The following software is required to develop using PhpSpreadsheet:
**PHP version 5.6 or newer**
PHP extension php_zip enabled
PHP extension php_xml enabled
PHP extension php_gd2 enabled (if not compiled in)
Try upgrading PHP.

ZF3 Zend\Math\Rand "This PHP environment doesn't support secure random number generation." PHP 5.6 with Mcrypt and openssl

I'm using ZF3 and have just configured an application on a new server and I get the following error when generating CSRF tokens
This PHP environment doesn't support secure random number generation. Please consider upgrading to PHP 7
The server is running PHP 5.6.28 so I checked the ZF3 migration guide which states:
"This message should appear if your are using PHP versions less than 7 on Windows machines without one of the following extensions or libraries installed:
Mcrypt
libsodium
CAPICOM
OpenSSL"
The server has both Mcrypt and OpenSSL. I'm also using the random_compact library as required. Any idea what I'm missing? Or is PHP 7 the only solution? Thanks.
This caused by Zend\Math\Rand::getBytes() using random_bytes() function. This function was added to PHP in PHP 7.0
http://php.net/manual/en/function.random-bytes.php
If you cannot upgrade your PHP Version, you can check this userland implementation for PHP 5.2 to 5.6
https://github.com/paragonie/random_compat
Although this library has been examined by some security experts in the PHP community, there will always be a chance that we overlooked something. If you are using an unsupported version of PHP, please upgrade as soon as possible.

Failed installation of zend-escaper with Composer

I'm trying to install zend-escaper but I'm getting this error:
This is strange as my PHP version (from phpinfo()) is 5.5.19, the message claims it is 5.3.5(!) which should satisfy the requirement anyway.
My ZF version is 1.12.13
I'm using PHP Storm
Can anyone help please?
Thanks
Tomasz
The PHP version on the command line can be a different executable than the PHP running inside the web server. It also can use a different pho.ini configuration file.
So if Composer states the PHP it is using is 5.3.5, this is correct because Composer is directly asking the PHP it is running on for its version. The problem is when this PHP version on the command line is way older then the PHP version in the web server.
Try to update your command line PHP.
Some more things to say: the version 5.3.5 is lower than the required 5.3.23, because the last number in the version is 5 compared with 23, and 5 is less than 23. So the version you are using is below the minimum requirement for zend escaper - at least in the version 2.5.1 you try to use. Such an old PHP was last supported in the 2.2 framework versions, so you might as well try to depend on ~2.2. However this will simply be a workaround for the old cli version.
One other note: You are in the process of installing a zend framework 2 component - don't expect your installed zend framework 1 to support any fancy stuff on its own. It is possible to mix classes with namespaces and without, and even use zf2 things together with zf1, but zf1 won't offer any automatic functionality to use these.

PHP intermittently unable to load json.so (PHP 5.4.19 on Ubuntu 12.04 LTS)

I'm using Ubuntu 12.04 LTS and needed PHP 5.4 so I'm using Ondřej Surý's (php5-oldstable) package.
Both phpinfo and the CLI show that JSON is enabled:
#php -i | grep -i json
json
json support => enabled
json version => 1.2.1
My application mostly works. But periodically (approx one page refresh in ten) there is a PHP error. This only happens intermittently.
PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/json.so'
- /usr/lib/php5/20100525+lfs/json.so: cannot open shared object file:
No such file or directory "json.so"
How do I fix this?
I think that possible culprit (as I have answered in email) is that you are loading json extension somewhere from the configuration file.
The JSON extension is compiled in the core for PHP 5.4, so you should not load it by hand.
Please check that you don’t have:
json.ini somewhere in the /etc/php5/{mods-available} left over from previous PHP 5.5 installation
you are not loading JSON extension from the mentioned script, e.g. no dl(json.so).
Make sure you have stopped and started Apache2 (same applies to php5-fpm) when changing major versions. The symptoms might indicate that there was some stuck Apache2 thread with previous PHP from package loaded (that would be PHP 5.5 with json-c based JSON extension in this case).
Since you're saying that the json extension is loaded in phpinfo()'s output you could be dealing with a bug. Have you checked if the module file is actually there in the filesystem?
You have the following options:
Compile PHP 5.4 from source with Apache 2.4
Upgrade to the same repo's stable version which will give you PHP 5.5 + Apache 2.4.
Submit a bug with the Ondrej in Ubuntu's PPAs and wait for it to be resolved.
For more information check the debphp site.
Submitting a bug is a must, since if it is a real one it must be fixed for all users.
You could firstly go with option 2 if you don't conflict with the Migration guidelines like backward compatibility, deprecated functions, etc.. SO check it and decide.
It also strongly varies depending on the machine you have to do this with. If it is a critical production server, you may not want to compile of change versions on it. Go file the bug and see what the package maintainers have to say about this.
Also please write a reply here when your problem is resolved. I am quite curious as to what it is and hopefully was. :D
One point that doesn't diagnose or solve the issue (and seems to refer to PHP 5.5), but might help with tracing its root cause:
This Debian bug report and Phil Sturgeon's blog explain that some Linux distributions have chosen to replace the official PHP implementation of ext/json with the drop-in compatible pecl-json-c. The rationale was that Douglas Crockford's implementation contains a non-free clause in the license ("The Software shall be used for Good, not Evil"). See also this blog post.

Mismatch between Php and Extension module

I am trying to install the following php extension. Microsoft Drivers for SQL Server for PHP.
I have tried both versions of the driver but both seem to mismatch the version of php i am running. I looked around and it appears I have to recompile the modules in order to match the php api version. But I don't have any idea how to do this.
Any ideas on how to make this work? Or maybe a simpler way to use PHP 5.4.7 to access SQL.
You can do it with some tricks, its not recommended but it will work fine and in my case, it has not crashed yet :)
Check your phpinfo() page for:
1-PHP extension API Number
2-Thread safe or non-thread safe version
3-(Windows) compiler version
1-For building your extension you need php.lib. It is in your PHP-server dev directory.
2-You need PHP header files for compiling your extension, after including PHP header files, go to PHP/Zend directory and open zend_modules.h file and change the #define ZEND_MODULE_API_NO 20060613to your PHP extension API number for example change it to #define ZEND_MODULE_API_NO 20090626.
3- If you use windows based servers the compiler version is important(VC8 - VC10), if your PHP was compiled with VC8, build the extension in VS2008 or use VC8 for building your project.
If you encounter any wired error just comment it. I spent 3 months to make this worked ;)

Categories