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

Parse Error : syntax error on line 1 > 1 | <?php PHP_VERSION #64

Closed
zeyadsharo opened this issue Feb 13, 2021 · 8 comments · Fixed by shufo/blade-formatter#223
Closed

Comments

@zeyadsharo
Copy link

zeyadsharo commented Feb 13, 2021

Template

Parse Error : syntax error on line 1 > 1 | <?php PHP_VERSION

Context (Environment)

Parse Error : syntax error on line 1 > 1 | <?php PHP_VERSION

  • write your environment

php 7.4
laravel 8

Description

image

@betomedin
Copy link

php 5.6
Laravel 4.2

@brada1703
Copy link

I'm having the same issue with PHP 8.0.2 and Laravel 8.12

@furopi
Copy link

furopi commented Mar 5, 2021

I'm getting this error too. Please help...
php 8.0.2
Laravel 8

@shufo
Copy link
Owner

shufo commented Mar 6, 2021

Seems

<?php PHP_VERSION

is not right PHP syntax because PHP_VERSION is constant.

❯ php
<?php PHP_VERSION

Parse error: syntax error, unexpected end of file in Standard input code on line 2

Below syntax is ok

❯ php
<?php
echo PHP_VERSION;
7.4.8

Can you provide any example template?

@furopi
Copy link

furopi commented Mar 6, 2021

It happens with the default Laravel start page.... The sample page that is provided after a fresh Laravel 8 installation.

@shufo
Copy link
Owner

shufo commented Mar 7, 2021

It seems parse error while formatting {{ PHP_VERSION }} as php string.

To workaround this, you can use phpversion() function as equivalent code on welcome.blade.php

<div class="ml-4 text-center text-sm text-gray-500 sm:text-right sm:ml-0">
    Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ phpversion() }})
</div>

CLI test

echo "{{ phpversion() }}" | ./bin/blade-formatter --stdin
{{ phpversion() }}

@furopi
Copy link

furopi commented Mar 14, 2021

Ok, I can live with that. But honestly I think this problem should be fixed for other users who tend to not read the docs and will abandon the plugin or think it's not working... Just my two cents...

On the other hand I must say you did a very decent job with this plugin, using it on a daily basis! Taihen yoku gambarimashita, Shuhei-san. Doumo arigatou gozaimasu! Greetings from Germany 🍺 to Japan 🗾, Florian

@shufo
Copy link
Owner

shufo commented Mar 14, 2021

Just released v0.7.3 with this issue fixed.
Thanks for reporting issue @zeyadsharo @furopi @brada1703 @betomedin !

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

Successfully merging a pull request may close this issue.

5 participants