0

Currently I use this structure:

app/
bootstrap/
vendor/
public/

I would like to change it to

app-2/
bootstrap-2/
vendor-2/
public/

How to do that, I mean, which files do I need to change the path?

RIght now I have tried to change paths in:

public/index.php

then in:

bootstrap/autoload.php

bootstrap/path.php

bootstrap/start.php

Basically I have changed every /app/ to /app-2/ and the same for bootstrap and vendor.

But for some reason, the controllers from to app/controllers are executed instead of app-2/controllers

Any idea, if I am missing some file that needs to be edited also?

IN the debugger I see vendor-2, so that's correct, but why are loaded controllers from app instead of app-2 folder?

John Doeherskij
  • 2,269
  • 3
  • 13
  • 19
  • This is unlikely to work. At all. – ceejayoz Jul 27 '16 at 20:26
  • It has to work, why not? Why not to hardcode the paths then? – John Doeherskij Jul 27 '16 at 20:37
  • That's stupid if it's not possible. Is this fixed in Laravel 5? Or still not? What about Lumen? Are you able to define your own names for app,bootstrap and vendor folders there? – John Doeherskij Jul 27 '16 at 20:54
  • Lumen is Laravel-based, so it will be similarly difficult there. What are you trying to *accomplish* with this? – ceejayoz Jul 27 '16 at 20:55
  • I have multiple versions of the same project and A/B testing different configurations/environments. But man... this is like a shot in the heart. Why is it like this? I don't get it. Maybe I will end up with PhalconPHP after all ;( – John Doeherskij Jul 27 '16 at 21:38
  • That's a bit of a weird way of handling versions and A/B testing. You'd typically just deploy different branches of the app to two different locations on the server. – ceejayoz Jul 27 '16 at 22:14

1 Answers1

0

Change the app directory

To accomplish this, you'd need to update your composer.json file, since that is the one that ultimately determines how Laravel's autoloader behaves.

You should see a section similar to this:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},

change it to:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app-2/"
    }
},

That change will mean that when the autoloader comes across any class in the App namespace, it will try to load it from the app-2 directory. After making this change, you'll need to run the following CLI command to regenerate the autoloader's PHP files:

php composer.phar dump-autoload

That command may be slightly different depending on how you installed composer on your system.

Change the vendor directory

You can also change the install path of composer's packages from vendor to vendor-2 by adding another config option into composer.json.

Change the bootstrap directory

You'll need to update references to the bootstrap directory in the following files:

./public/index.php
./artisan
Community
  • 1
  • 1
David Smith
  • 593
  • 2
  • 10
  • thanks, it's a little bit complicated. It's a shame that it can't be changed easier. Do you know if CodeIgniter or some other framework can do it like I want. – John Doeherskij Jul 28 '16 at 05:01
  • To be honest, what you're trying to do is very hacky and I wouldn't recommend it. I just provided the answer to your question without opinion. If you explain what exactly you're doing this for, I may be able to help further with a cleaner solution – David Smith Jul 28 '16 at 18:33