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.
Related
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.
I have some trouble when I upgrade PHP version 5.4 on my site. My site is built with CodeIgniter framework. It's working fine in previous version. When I check error log I see this error
error: cannot stat directory: (root_directory/project name/index.php/home)
Premature end of script headers: php54-cgi
cannot stat directory
It is linux error, not the PHP. In most common case after upgrading PHP you have changed user and/or group running php binary and new one simply does not have permissions to code directory.
So the answer will be - change user/group thats's running php.
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.
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'];
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).