Strange PHP errors on mPDF and PHP 7 - php

I'm using mPDF 7.0 to generate PDF files on web app hosted on Shared hosting account and it works fine. I tested it on other shared hosting account also works fine, but when I uploaded on VPS server I got some strange php errors in some of the mPDF library core files. PHP version on VPS is 7.0.10 (on shared hosting accounts is also tested with PHP 7.X versions and works fine). mbstring, gd, bcmath extensions are enabled in php.ini.
Here is example of the error:
On line with this code only const SCALE = 72 / 25.4; I got this error "PHP Parse error: syntax error, unexpected '/', expecting ',' or ';' in /vendor/mpdf/mpdf/src/Mpdf.php on line 58". Also I got errors on "**" operator, etc.
If somebody experienced similar problem and have some solution I would appreciate any help to overcome this problem.
Thanks in advance.

Related

500 internal server error on fresh Laravel installation

I have just installed Laravel on my host following the official site's step by step guide and created an app called core, using the command
laravel new core
after seeing the success message I uploaded everything to my host, but when i try to access the /core/public folder from the browser i get 500 error on Chrome and nothing at all on firefox.
if i run the command
php artisan list
On SSH inside my core folder i get:
Status: 500 Internal Server Error
Content-type: text/html
Can anyone of you Laravel experts let me know please where did i go wrong?
thanks in advance
In the error log i found:
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in ...public_html/laravel/core/public/index.php on line 50
even though i haven't touched any files, line 50 is:
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
I checked all the requirement from Laravel and my server meets them all
PHP >= 5.5.9
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
The application key was successfully generated inside .env
Also Directories within the storage and the bootstrap/cache directories are writable by the web server with permission 755
Unexpected class for Kernel::class implies to me that you are running a version of PHP lower than 5.5. Laravel only works for 5.5.9+.
My guess is your server provider claims to have PHP 5.5+ support, but the boxes may come with 5.4 installed on them. You will need to contact your server admin to get them to upgrade it if you cannot upgrade it yourself.
PHP 5.5 is required because the ::class syntax was added in that version.

Get Goutte to work on shared host?

I installed Goutte on my local host using Composer. It works as expected when run using XAMPP. Then, I uploaded all the files from the vendor folder to server. Now, the script shows errors like:
syntax error, unexpected '[', expecting ')'in vendor/react/promise/src/functions.php on line 68
The file works perfectly without any modification on local host. What could be the possible reason?
I have the save problem, upgrade my php version to 5.4.x solve my problem.
By the way, it's better to use Goutte.phar in production environment.

Binary Beast API runs on local XAMPP, Parse errors on inmotionhosting.com

This is probably a beginners problem I will later feel dumb for not figuring out, but here goes:
I have been learning about the Binary Beast API and how to use it on a game fan site I volunteered on. The problem is that the code works flawlessly on my local XAMPP install, but when I upload it to a test server I get parse errors like this:
Parse error: syntax error, unexpected '[', expecting ')' in /home/allsta23/public_html/drawingboard/BinaryBeastAPI/lib/BBModel.php on line 654
I never modified any of the API libraries so the code within is exactly the same on my local install and likewise the same as the original code on github.
https://github.com/BinaryBeast/BinaryBeast_API_PHP
In this particular instance, line 654 of BBmodel looks like this:
653 if(!isset($result->result)) {
654 var_dump(['result' => $result, 'svc' => $svc, 'args' => $args]); die();
655 }
This has been driving me crazy because it doesnt have any errors when ran locally so I don't think it is a syntax error.
Has anyone seen anything that would cause that to happen? I feel like there is a problem in one of the web server or PHP config files that is causing this to happen, but I have no idea where it would be.
EDIT: I also forgot to add that the inmotionhosting webserver is running PHP 5.4 and my local XAMPP install is running 5.4.7 in case that matters.
Any help would be greatly appreciated.
Jesse
Well I didn't want to delete the post but I found out what the problem is. Even though the cpanel config says it will handle all *.php files as 5.4 version files, the server is still only 5.3 ( I don't get it? ) and it can't be updated on shared hosting. Long story short it was the php 5.4 array shorthand notation that caused the problem.

CakePHP Migration Errors

I'm migrating my CakePHP site from a local Xampp installation to an EC2 ubuntu environment. I moved over the DB, and copied the web directory files over to the EC2 instance, but upon accessing the site I get this error:
Fatal error: Class 'AppController' not found in /var/www/cakephp/lib/Cake/Controller/CakeErrorController.php on line 31
I looked into the Apache error log and found that the piece it wasn't liking was this:
$this->Auth->user()['role']
The error said the PHP parser wasn't expecting the '['. This all worked fine in the default local Xampp install, so I'm assuming this is a PHP difference between the two installs?
Xampp: PHP 5.4.7
EC2: PHP 5.3.10
Any idea of any settings or anything that could cause this behavior?
That is a new feature in php 5.4 see http://docs.php.net/manual/en/migration54.new-features.php the third bullet item.
For php 5.3 you will need to assign it to a variable
$user = $this->Auth->user()
$role = $user['role'];

What version of PHP started supporting the following syntax?

on my server (Centos5) i have PHP 5.2, i'm unable to update it, i read somewhere that PHP 5.4 won't work on Centos5, didn't inspect enough as i am in the middle of a lot of projects, anyways, here is the syntax :
$data['trees'] = (new Tree())->where('parent_id',0)->get();
On my WAMP it runs on PHP 5.4.3, on the server it gives me the following error:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR
Support for accessing instance members directly after a new expression was introduced in PHP 5.4 (finally). Note that the parentheses are required around the new expression, as in your given line of code, or it won't work.
I haven't heard of any particular server configurations or platforms where this won't work when running PHP 5.4. If it causes an error on a server where PHP 5.4 is installed, it's likely that's not the version that's interpreting your script (check your server config, .htaccess, and INI directives).

Categories