Support the ongoing development of Laravel.io →
Configuration

On 5.0 I used to make a storagepath.php in app/ which contained the following:

<?php namespace Myapp;

class Application extends \Illuminate\Foundation\Application {
	public function storagePath() {
	    return \Helpers\Envconfig::getEnvConfig('storage.main_path');
	}
	public function publicPath() {
		return $this->basePath.'/webroot';
	}
}

My Envconfig helper is still setting everything just fine, so no need to show that code.

Then in bootstrap/app.php I would invoke the app as follows


$app = new Myapp\Application(
	realpath(__DIR__.'/../')
);

With 5.1, however, when I composer install I get the message:

[RuntimeException]
Error Output: PHP Fatal error: Cannot redeclare class Illuminate\Contracts
\Container\Container in /www/bootstrap/cache/compiled.php on line 4

Any ideas on what my issue might be?

Last updated 3 years ago.
0

Curiously, if I delete compiled.php from bootstrap/cache and remove all traces of:

		"php artisan clear-compiled",
		"php artisan optimize"

From my composer.json, it works just fine. Not optimal though, anybody have any ideas? Here is my composer.json without the edits:


{
	"name": "someapp/laravel-boilerplate",
	"description": "laravel Boilerplate CMS",
	"keywords": ["framework", "laravel", "boilerplate"],
	"license": "MIT",
	"type": "project",
	"require": {
		"laravel/framework": "5.1.*",
        "illuminate/html" : "5.*",
        "mcamara/laravel-localization": "1.0.*",
        "laravel/socialite" : "~2.0",
        "twbs/bootstrap": "3.*",
        "twbs/bootstrap-sass": "3.*",
        "fortawesome/font-awesome": "4.*",
        "hieu-le/active": "~2.0"
	},
	"require-dev": {
        "phpunit/phpunit": "~4.0"
	},
	"autoload": {
		"classmap": [
			"database"
		],
		"psr-4": {
			"App\\": "app/"
		},
        "files": [
        	"app/carbonate.php",
            "app/helpers.php",
            "app/helpers/envconfig.php"
        ]
	},
	"autoload-dev": {
		"classmap": [
		"tests/TestCase.php"
		]
	},
	"scripts": {
		"post-install-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
        "pre-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
		"post-update-cmd": [
			"php artisan optimize"
		],
		"post-create-project-cmd": [
			"php -r \"copy('.env.example', '.env');\"",
			"php artisan key:generate"
		]
	},
	"config": {
		"preferred-install": "dist"
	}
}

Last updated 9 years ago.
0

Not sure why it is acting odd.

I posted the code I use to extend Laravel's application for custom paths at https://github.com/TerrePorter/LaravelFrameworkLoader

For your code, it would be something like this in the bootloader\app file

$app = new Wpb\Laravel_Framework_Loader\Application (
    [
        'base' => realpath(__DIR__.'/../'), 
        'public' => realpath(__DIR__.''/webroot''),
        'storage' => \Helpers\Envconfig::getEnvConfig('storage.main_path')
    ]
);

Hope that helps.

0

Sure did, thanks a million!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

CrowdForge crowdforge Joined 18 Aug 2015

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.

© 2025 Laravel.io - All rights reserved.