Support the ongoing development of Laravel.io →
posted 10 years ago
Configuration
Last updated 2 years ago.
0

Does anyone have any possible solutions? I have tried everything. Re-install, composer update, etc. This happens on A2 hosting and Hostgator.

Here is the error live.

Last updated 2 years ago.
0

Make sure you're running PHP >= 5.3.

Last updated 2 years ago.
0

Here is my .htaccess:

# Use PHP 5.3
AddHandler application/x-httpd-php-53 .php

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

To make sure I also switched the php version manually in the CPanel to PHP 5.3.8

Last updated 2 years ago.
0

Make sure that when running php from the cli it's using >= 5.3:

php -v
Last updated 2 years ago.
0

The error message relates to the use of traits, however the current releases of Laravel do not use traits. If you go to Illuminate/Support/Str.php in the current release (4.1.28) you should see the following:

<?php namespace Illuminate\Support;

class Str {

	/**
	 * The registered string macros.
	 *
	 * @var array
	 */
	protected static $macros = array();

Line 7 is just a comment, so it can't be the cause of that error. If you look at the development version of that file:

<?php namespace Illuminate\Support;

use Illuminate\Support\Traits\MacroableTrait;

class Str {

	use MacroableTrait;

Line 7 is requesting a trait, which would cause the error you're experiencing (PHP 5.4.0 is required for traits). I suspect that the problem is you're using the development version of Laravel -- which isn't a good idea in production -- and the development version of Laravel requires PHP 5.4.0.

Please paste the contents of your composer.json file, it's very likely you either have "minimum-stability" set to dev (instead of stable) or you're explicitly requiring the development version of Laravel.

If this is the case (and using the development version is your goal) you'll need to update to PHP 5.4.0.

Last updated 2 years ago.
0

Still not working. Here is my .htaccess:

# Use PHP 5.3
AddType application/x-httpd-php53 .php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Here is my composer.json:

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": ["framework", "laravel"],
	"license": "MIT",
	"require": {
		"laravel/framework": "4.1.*"
	},
	"autoload": {
		"classmap": [
			"app/commands",
			"app/controllers",
			"app/models",
			"app/database/migrations",
			"app/database/seeds",
			"app/tests/TestCase.php"
		]
	},
	"scripts": {
		"post-install-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-update-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-create-project-cmd": [
			"php artisan key:generate"
		]
	},
	"config": {
		"preferred-install": "dist"
	},
	"minimum-stability": "stable"
}

I did notice that when I click on composer.json file on live server it shows "laravel/framework": "4.2.*" How is that even possible for the file to change. This does not make sense.

I also tried updating composer with laravel/laravel":4.1.*" instead of laravel/framework.

Last updated 2 years ago.
0

Here is the working version when I did a clean install a few months back.

Here is the error version when I try to do a clean install now.

Last updated 2 years ago.
0

@ citricsquid

What is the exact link I should be cloning laravel so I do not accidentally get the dev version?

Last updated 2 years ago.
0

I'm not sure what you mean wrt "cloning laravel", if you you follow the install instructions on the Laravel docs (composer create-project laravel/laravel --prefer-dist) you'll get the project files for the latest release (4.1.28) with a composer.json requiring Laravel 4.1, you should never end up with the development version unless you explicitly require it.

I'm not really sure why (or how) your composer.json went from requiring Laravel 4.1 to 4.2 when you moved the file to production, perhaps there's a reason that someone else will know. For now just change it back to 4.1 and everything should work.

Last updated 2 years ago.
0

I started from scratch again. This time I did what you said. I still have the same error

php composer.phar create-project laravel/laravel
curl -S getcomposer.org/installer | php
php composer.phar install
php composer.phar update

I also added this to my .htaccess:

# Use PHP 5.3
AddType application/x-httpd-php53 .php

I also tried php54. I also left .htaccess as default file and changed php version to 5.3 and then tried 5.4 on A2 hosting in Cpanel. Still no change from the original error. This is frustrating.

Last updated 2 years ago.
0

Here is my result:

$ composer create-project laravel/laravel
Installing laravel/laravel (v4.1.27)
  - Installing laravel/laravel (v4.1.27)
    Downloading: 100%
    [...]
  - Installing laravel/framework (v4.1.28)
    Downloading: 100%
    [...]

$ head -10 laravel/vendor/laravel/framework/src/Illuminate/Support/Str.php

<?php namespace Illuminate\Support;

class Str {

        /**
         * The registered string macros.
         *
         * @var array
         */
        protected static $macros = array();

I'm at a complete loss as to why you could be experiencing this, perhaps I'm missing something blindingly obvious and someone else with fresh eyes can identify the problem. Just to make absolutely sure I haven't misdiagnosed the problem, please can you paste the contents of composer.json (the file on the server) and the contents of vendor/laravel/framework/src/Illuminate/Support/Str.php (the file on the server).

Edit: this is a long shot and perhaps impossible, but could your web host be running a local mirror of composer and have the dev version? That seems exceptionally unlikely but...

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

swgj19 swgj19 Joined 11 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.