Question

Ok, newbie at Laravel. I used composer to download laravel. It created a directory structure like...

  vendor\laravel\laravel\app
  vendor\laravel\laravel\bootstrap
  vendor\laravel\laravel\public
  vendor\laravel\framework\....
  vendor\laravel\laravel\composer.json

along with many other vendor and laravel directories.

and where my initial composer.json file was in the root directory.

I moved the contents of the vendor\laravel\laravel directory to the top level so that I have a directory structure like...

   app\...
   bootstrap\...
   public\...
   vendor\laravel\framework\...
   composer.json
   vendor\ many other directories...

I updated the index.php directory so that it referred to the new locations of the bootstrap\autoload.php and bootstrap\start.php directories.

I can load the index.php and I get the Laravel image map signifying that all is working.

So, now I go and modify the routes.php to be...

Route::controller('home', 'HomeController');

and try to load the home directory. I get the error...

"include(D:\dev\wamp\www\ltest3\vendor/laravel/laravel/app/controllers/BaseController.php): failed to open stream: No such file or directory"

The problem is that the vendor\composer\autoload_classmap.php still has the old laravel\app controller mappings. e.g.

return array(
    'BaseController' => $vendorDir . '/laravel/laravel/app/controllers/BaseController.php',
    'DatabaseSeeder' => $vendorDir . '/laravel/laravel/app/database/seeds/DatabaseSeeder.php',
    'HomeController' => $vendorDir . '/laravel/laravel/app/controllers/HomeController.php',

instead of the new location at /app/controllers/

If I try to run composer update on the composer.json in my root directory, I get error after awhile of processing...

 Failed to execute git status --porcelain --untracked-files=no        

So, not sure how to get composer to update the autoload classmap to use my new directory location.

Do people normally leave the vendor\laravel\laravel directory in is original location?

Seems that the composer will probably attempt to update the laravel directory again, but not sure since I get the error.

Here is my full composer.json in the root directory. This was the one that was originally in the vendor\laravel\laravel directory and created by other initial composer run, maybe that is problem.

{
    "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"
}
Was it helpful?

Solution 2

Got it working, thanks to Cryode and user2094178 pointing out that my directory structure was not correct to start off with. I am going to go over several of the issues that I ran into, hopefully helping others that may have the same problem. fyi, this is on Windows 7 running WAMP.

I think where things all went wrong was that I tried to install Laravael by creating a composer.json file with a require of laravel. When running composer, it didn't know that I wanted Laravel as my main project framework, so it just installed all of Laravel down in the vendor directory. There were no top-level app, bootstrap, public, etc. directories.

Scrapped this install and started off from scratch using the directions specified at http://geekanddummy.com/how-to-laravel-4-tutorial-part-1-installation/ (e.g. ran composer create-project laravel/laravel). Ran into the following issues...

1) composer/git complains about https issues. composer continued with warnings on every download but continued to download files using http. When it got to symfphony filesystem.git, it got a fatal error

Failed to clone git@github.com:symfony/Filesystem.git via git, https, ssh protocols, aborting

To resolve this I ran a small php script that output phpinfo(). Determined the location of my php.ini file and removed the comment for "extension=php_openssl.dll". I had already done this for WAMP and Apache, but found out PHP at the command line was using a different php.ini

2) Did a test of git and ssl using "ssh git@github.com" at the command line. Had an issue that it could not authenticate, permission denied. Added environment variable HOME, set it to ..

set HOME=%HOMEPATH%

After this, ssh worked and added an ssh key successfully for github.

3) Deleted the entire project directory and started back from scratch, did not see a way to recover and continue. Next issue was that I got a git error "exceeded the timeout of 300 seconds" when retrieving symfony/Filesystem.git. Fixed this by adding the following composer environment variable..

 set COMPOSER_PROCESS_TIMEOUT=2000

4) Deleted entire project and started again from scratch. All was downloaded fine this time. I have the top level app, bootstrap, public, and vendor directories. Loading the laravel\public\index.php works, I see the "You have arrived" page.

OTHER TIPS

All vendor files whether they belong to Laravel or third party should be in the same location /vendor. This is not just a amtter of mapping in bootstrap but this is important for when you need to update any package in composer. You might need to do this on a delicate environment so why not keep it as it should be? Is there a reason?

Composer is used on many other frameworks and I believe that in all of them you need a vendor directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top