Skip to content
This repository has been archived by the owner on Mar 13, 2019. It is now read-only.

run laravel new blog is failed #57

Closed
ozbillwang opened this issue Apr 23, 2016 · 6 comments
Closed

run laravel new blog is failed #57

ozbillwang opened this issue Apr 23, 2016 · 6 comments

Comments

@ozbillwang
Copy link

ozbillwang commented Apr 23, 2016

For the install instruction, I run below command to create a new project.

$ cat /usr/local/bin/composer
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
echo "Current working directory: '"$(pwd)"'"
docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer $@

$ composer
Current working directory: '/Users/bill/composer'
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0.0 2016-04-05 13:27:25

problem 1

If I run composer global require "laravel/installer", the command runs well, but there is no new folders generated.

So I have to manually created a composer.json file, and this time I got all vendor folders.

$ cat composer.json
{
    "require": {
        "laravel/installer": ">=1.3.3"
    }
}

$ composer install

problem 2

I need create a new project, I run below command:

$ vendor/bin/laravel new blog
...
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Generating autoload files
Application ready! Build something amazing.

I found the APP Key is not automatically generated, if I run the command manually:

$ php artisan key:generate

Warning: require(/Users/bill/composer/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/bill/composer/blog/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/Users/bill/composer/blog/bootstrap/../vendor/autoload.php' (include_path='.:') in /Users/bill/composer/blog/bootstrap/autoload.php on line 17

then I run with composer create-project --prefer-dist laravel/laravel blog, this time everything works fine.

$ composer create-project --prefer-dist laravel/laravel blog
...
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
@RobLoach
Copy link
Owner

Nice job on the composer script. @renatomefidf brought up some good permissions tips in #35 . Would end up adding --user $(id -u) to the command.

What is APP_Key in this case?

@ozbillwang
Copy link
Author

ozbillwang commented Apr 24, 2016

@RobLoach

Regarding APP_Key, I follow the instruction in Laravel installation

Regarding #35 you mentioned, I am not sure if related with my problem or not.

@ozbillwang
Copy link
Author

ozbillwang commented May 7, 2016

Maybe I knew the reason for the first problem.

$ composer global config bin-dir --absolute
Current working directory: '/Users/bill/github'
Changed current directory to /composer
/composer/vendor/bin

With global option, the package were installed to container's folder /composer/vendor/bin, but our container only exposes /app folder. That's why I didn't see anything after I run composer global require "laravel/installer"

So it is a bug in this docker image, which doesn't support global option in composer.

@ozbillwang
Copy link
Author

@RobLoach Seems you have added the global path into Dockerfile at

ENV PATH /composer/vendor/bin:$PATH

Can you explain how to make it work with composer global require "laravel/installer"

@ozbillwang
Copy link
Author

ozbillwang commented May 8, 2016

I'd like to change the WORKDIR in base Dockerfile, but I can't build the base image directly (reported in #66), here is my work around to fix this issue.

$ cat Dockerfile
FROM composer/composer
WORKDIR /composer

$ docker built -t composer . 

$ cat /usr/local/bin/composer
#!/bin/sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
echo "Current working directory: '"$(pwd)"'"
docker run --rm -v $(pwd):/composer -v ~/.ssh:/root/.ssh composer $@

So I change the WORKDIR to /composer in Dockerfile and composer script.

Now I am fine to run composer with global option.

@RobLoach
Copy link
Owner

RobLoach commented May 8, 2016

@SydOps Thanks for looking into this... Updated the installer hash at #67 , mind reviewing?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants