Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error with Laravel 5.5 and PHP 7.0.27 within Mail function #22955

Closed
kskrlin opened this issue Jan 29, 2018 · 15 comments
Closed

Syntax Error with Laravel 5.5 and PHP 7.0.27 within Mail function #22955

kskrlin opened this issue Jan 29, 2018 · 15 comments

Comments

@kskrlin
Copy link

kskrlin commented Jan 29, 2018

  • Laravel Version: 5.5.32
  • PHP Version: 7.0.27

Description:

Parse error: syntax error, unexpected '?', expecting variable
in
/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php

Steps To Reproduce:

It happens when I am trying to send an email using Mail::to()...

It doesn't happen with PHP 7.1.8.
How to fix this issue without downgrading Laravel version (with 5.4 worked, as I recall) or changing PHP (because this version is on shared server and I am unable to change it)

@laurencei
Copy link
Contributor

laurencei commented Jan 29, 2018

Did it give a line number?

Are you sure your running PHP7? That error looks alot like PHP5.6 trying to run PHP7 code...

@kskrlin
Copy link
Author

kskrlin commented Jan 29, 2018

Yes, it is 7.0.27.
The error is occurred on lines: 46, 51, 56
?string $value
this new nullable type syntax is introduced since php 7.1, but Laravel 5.5 requires at least 7.0, not 7.1, hence the issue...

@laurencei
Copy link
Contributor

ping @GrahamCampbell - your the composer expert 😄 .

@laurencei
Copy link
Contributor

laurencei commented Jan 29, 2018

actually - @kikky7 - did you run composer install on the PHP7.1 system, then copy this to a PHP7.0 system?

Because technically the composer.json of css-selector has a restraint of PHP7.1 - so you shouldnt get that version anyway. You need to run composer update on 7.0 to get the right versions.

@kskrlin
Copy link
Author

kskrlin commented Jan 29, 2018

Composer packages are only installed and updated locally on 7.1 and copied to server, where is 7.0.
I ran fresh composer install and still getting css-selector with 7.1 syntax.

I will manage to get 7.1 on server, but it would be nice to have some other solution also.

@laurencei
Copy link
Contributor

laurencei commented Jan 29, 2018

Composer packages are only installed and updated locally on 7.1 and copied to server, where is 7.0.

Yeah - you cant do this. The problem is composer is installing packages that need PHP 7.1 - because you are running PHP7.1.

If you want to run on PHP7.0- then you must run composer update (not install) on the PHP7.0 machine, and it will handle it correctly for you.

@GrahamCampbell
Copy link
Member

You need to use the platform config to lock to the version of php you want to use:

{
    ...
    "config": {
        "platform": {
            "php": "7.0.27"
        },
    ...
    },
    ...
}

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Jan 29, 2018

That way, when you generate a lock file on a newer version of php, your dependencies will still work on php 7.0.27.

@GrahamCampbell
Copy link
Member

You can also require "symfony/lts": "^3.0", to stop composer from resolving any symfony 4 dependencies. It'll make it resolve 3.4 LTS.

@nathanpurcell
Copy link

As far as I can see nullable types were only added to PHP in v7.1, but the required version is >=7.0.0
The issue appears to be with Symfony, but if Laravel 5.5 is a LTS version perhaps the PHP requirement should be updated to 7.1?

@devcircus
Copy link
Contributor

See the above comments. The dependencies are correct.

@pixelzdesign
Copy link

@GrahamCampbell Where to put this "symfony/lts": "^3.0"?

@Rolice
Copy link

Rolice commented Aug 30, 2018

Some Symfony packages are incompatible (introduction of nullable concept in PHP) with PHP 7.0.
This means that Laravel 5.5 requires effectively PHP 7.1.

@laurencei
Copy link
Contributor

@Rolice - no, because Composer will detect those packages and install PHP 7.0 equilivant for Symfony.

@Rolice
Copy link

Rolice commented Aug 31, 2018

It is strage as it is brand new Docker image with composer install and it breaks. Could be some version overlapping issue, though. I have used composer new project to create the project with specific version of Laravel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants