<p>The error likely indicates some language construct or syntax that is valid in PHP 7.4 but isn't in 7.2 – for example, <a href="https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc" rel="nofollow noreferrer">indented heredoc strings</a> only work in PHP 7.3 and above and would produce the <code>Unexpected end of file</code> error in previous versions.</p>
<p>In general, make sure to test your plugin in your development environment against all PHP versions you intend to support. For a new plugin, I wouldn't bother supporting older PHP versions that aren't supported any more. Right now, <a href="https://www.php.net/supported-versions.php" rel="nofollow noreferrer">PHP 7.3 is close to end-of-life</a> (security support until december 2021), so for a new plugin I would require 7.4.</p>
<p>Make sure to include the minimum supported PHP version in your <code>composer.json</code> so Composer will warn users trying to install the plugin using older versions:</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;require&quot; : {
        &quot;php&quot; : &quot;&gt;=7.4&quot;,
    }
}
</code></pre>
<p>See <a href="https://getcomposer.org/doc/04-schema.md#require" rel="nofollow noreferrer">composer.json schema</a>.</p>
<p>For the record, you should update your staging server. PHP 7.2 has been out of security support for a year. Also, you should always try to match environments between development, staging and production as close as possible. Developing on PHP 7.4 and deploying on 7.2 will cause headaches like this that can be easily avoided.</p>

CC BY-SA 4.0
2021-11-02T10:59:38.137Z
Thank you for this! I've been out of the PHP world for a few years and hadn't realised 7.2 wasn't supported anymore. I'll be sure to update everything to 7.4 going forward and do my best to keep versions consistent.
samroberts707
CC BY-SA 4.0
2021-11-02T10:51:08.680Z
2021-11-02T10:51:08.680Z
MoritzLost
<p>I'm making a new Plugin for CraftCMS, it works fine locally but when I call the services class on our staging server it throws a Syntax Error, Unexpected end of file.</p>
<p>I've installed them both through Composer in the same way, (Symlink in composer.json pointing to local directory.)</p>
<p>I've tried adding &quot;?&gt;&quot; to the end of my PHP file incase that was the issue but didn't resolve. I've also doubled checked all my closing brackets which seem to be fine.</p>
<p>The only difference I can think is maybe PHP version? Locally im on 7.4 and the staging server is 7.2.</p>
<p>Any help would be appreciated.</p>

CC BY-SA 4.0
2021-11-02T10:43:56.583Z
Can you post the file that is causing the error? Hard to tell what's causing the error without seeing the code.
MoritzLost
<craft3><plugin-development><composer>
Composer Unexpected end of file on new plugin
# Composer Unexpected end of file on new plugin

(Asked by: username_0 on 2021-11-02)

I'm making a new Plugin for CraftCMS, it works fine locally but when I call the services class on our staging server it throws a Syntax Error, Unexpected end of file.

I've installed them both through Composer in the same way, (Symlink in composer.json pointing to local directory.)

I've tried adding "?>" to the end of my PHP file incase that was the issue but didn't resolve. I've also doubled checked all my closing brackets which seem to be fine.

The only difference I can think is maybe PHP version? Locally im on 7.4 and the staging server is 7.2.

Any help would be appreciated.

**Tags:** craft3, plugin-development, composer
> **Comments:**
> **username_1**: Can you post the file that is causing the error? Hard to tell what's causing the error without seeing the code.  

---

## 1 answers

### Answer by username_1 on 2021-11-02. Score: 1 | Accepted answer

The error likely indicates some language construct or syntax that is valid in PHP 7.4 but isn't in 7.2 – for example, indented heredoc strings only work in PHP 7.3 and above and would produce the Unexpected end of file error in previous versions.
In general, make sure to test your plugin in your development environment against all PHP versions you intend to support. For a new plugin, I wouldn't bother supporting older PHP versions that aren't supported any more. Right now, PHP 7.3 is close to end-of-life (security support until december 2021), so for a new plugin I would require 7.4.
Make sure to include the minimum supported PHP version in your composer.json so Composer will warn users trying to install the plugin using older versions:
{
    "require" : {
        "php" : ">=7.4",
    }
}

See composer.json schema.
For the record, you should update your staging server. PHP 7.2 has been out of security support for a year. Also, you should always try to match environments between development, staging and production as close as possible. Developing on PHP 7.4 and deploying on 7.2 will cause headaches like this that can be easily avoided.

> **Comments:**
> **username_0**: Thank you for this! I've been out of the PHP world for a few years and hadn't realised 7.2 wasn't supported anymore. I'll be sure to update everything to 7.4 going forward and do my best to keep versions consistent.  

---

