reflexions / docker-laravel

Docker container for Laravel 5 applications
https://reflexions.co
42 stars 9 forks source link

error when running laravel container #5

Closed hopewise closed 8 years ago

hopewise commented 8 years ago

Hello,

Thank you for this great image, however, I got error:

 [RuntimeException]
  Error Output: PHP Fatal error:  Class 'Reflexions\DockerLaravel\DockerApplication' not found in /var/www/laravel/bo
  otstrap/app.php on line 14

I could not add a key for all, I try php artisan key:generate I get the above error

If I try to run composer install, I got:

# composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
PHP Fatal error:  Class 'Reflexions\DockerLaravel\DockerApplication' not found in /var/www/laravel/bootstrap/app.php on line 14
Script php artisan clear-compiled handling the post-install-cmd event returned with an error

  [RuntimeException]
  Error Output: PHP Fatal error:  Class 'Reflexions\DockerLaravel\DockerApplication' not found in /var/www/laravel/bo
  otstrap/app.php on line 14

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

Please advice

hopewise commented 8 years ago

I've noticed that this error occurs only if I have an existing app

patsplat commented 8 years ago

The default laravel application does not allow storage and cache directories to be configured. This is a common source of permissions errors. It is possible to subclass the application to configure these parameters.

The setup script attempts to

composer require reflexions/docker-laravel

and then update bootstrap/app.php to use Reflexions\DockerLaravel\DockerApplication

It sounds like the first step failed, and the second step succeeded.

patsplat commented 8 years ago

Could you try adding the composer dependency by hand? And confirm that the app is running laravel 5.x?

patsplat commented 8 years ago

It may be necessary to remove the following from composer.json so you can run composer install, then add them back afterwards:

"scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
hopewise commented 8 years ago

I tried to run from inside container:

root@e0a4fa7ef758:/var/www/laravel# composer require reflexions/docker-laravel

But here is what I got:

Using version ^1.0 for reflexions/docker-laravel
./composer.json has been updated
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package laravelcollective/html == 5.2.4.0 could not be found.
  Problem 2
    - Conclusion: remove laravel/framework v5.2.14
    - Conclusion: don't install laravel/framework v5.2.14
    - laravelcollective/html v5.1.0 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.1 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.2 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.3 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.4 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.5 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.6 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.7 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.8 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - laravelcollective/html v5.1.9 requires illuminate/session 5.1.* -> satisfiable by illuminate/session[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.6, v5.1.8].
    - don't install illuminate/session v5.1.1|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.13|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.16|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.2|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.20|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.22|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.25|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.28|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.6|don't install laravel/framework v5.2.14
    - don't install illuminate/session v5.1.8|don't install laravel/framework v5.2.14
    - Installation request for laravel/framework == 5.2.14.0 -> satisfiable by laravel/framework[v5.2.14].
    - Installation request for laravelcollective/html 5.1.* -> satisfiable by laravelcollective/html[v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.1.4, v5.1.5, v5.1.6, v5.1.7, v5.1.8, v5.1.9].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
root@e0a4fa7ef758:/var/www/laravel#

then, I have manually copied the reflexions folder into the vendors folder, Although I have "reflexions/docker-laravel": "^1.0" in the composer.json at "require", but it I've got:

root@e0a4fa7ef758:/var/www/laravel# php artisan serve
PHP Fatal error:  Class 'Reflexions\DockerLaravel\DockerApplication' not found in /var/www/laravel/bootstrap/app.php on line 14

The only way it worked for me is set $app as:

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

So, what do you advice please?

patsplat commented 8 years ago

Reverting app back to Illuminate\Foundation\Application should run. Will look into the laravel dependency on the reflexions/docker-laravel package.

hopewise commented 8 years ago

if Reverting app back to Illuminate\Foundation\Application should run, then can you please explain what does reflexions/docker-laravel do? Also, how would I debug my app using xdebug??

On Tue, Feb 16, 2016 at 2:55 PM, Patrick Way notifications@github.com wrote:

Reverting app back to Illuminate\Foundation\Application should run. Will look into the laravel dependency on the reflexions/docker-laravel package.

— Reply to this email directly or view it on GitHub https://github.com/reflexions/docker-laravel/issues/5#issuecomment-184670684 .

Kind Regards,

Samir Sabri Software Architect& Developer www.dcaclab.com Jordan-Middle East

patsplat commented 8 years ago

The only difference btw the two application classes is the relocation of cache files to /var/run/application

reflexions/docker-laravel provides Reflexions\DockerLaravel\DockerApplication

There can be permissions issues with the volume share btw your local source directory and the docker container. Often these are triggered by running artisan inside and outside of the container. The affected paths are usually laravel's storage and cache files.

Regarding xdebug, extending the Dockerfile allows customization of php extensions.

hopewise commented 8 years ago

Thanks patsplat