2

I am facing an issue with composer on Windows Server 20012 R2. I am trying to deploy a website and every time I run composer install or composer update I get the following:

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Script php artisan optimize handling the post-install-cmd event returned with an error


  [RuntimeException]
  Error Output:


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

And when I checked the php error log I find the following:

[17-Jul-2016 08:04:58 UTC] PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class log does not exist' in C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Container\Container.php:734
Stack trace:
#0 C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Container\Container.php(734): ReflectionClass->__construct('log')
#1 C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Container\Container.php(629): Illuminate\Container\Container->build('log', Array)
#2 C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(697): Illuminate\Container\Container->make('log', Array)
#3 C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Container\Container.php(849): Illuminate\Foundation\Application->make('Psr\\Log\\LoggerI...')
#4 C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\ in C:\PATH_TO_PROJECT\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 734

When I try the same project on an Ubuntu server everything works fin! I have tried every answer i could find on the internet, but nothing worked for me. Any advise on how to solve this? And why it is happening?

The windows server PHP version is 5.6.

composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "intervention/image": "^2.3",
        "greggilbert/recaptcha": "2.*",
        "laravelcollective/html": "5.2.*",
        "vsch/laravel-translation-manager": "*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
         "files": ["app/Http/Helpers/helpers.php"]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}
1
  • 1
    I changed APP_NAME value in .env file like "Example App" and got an error, so I used double quotes and its working fine. Commented Sep 30, 2017 at 11:34

4 Answers 4

3

I was able to fix this issue by removing any space in the values in the .env file e.g.:

MAIL_PORT= 587
MAIL_FROM_NAME=ABC Medical

to:

MAIL_PORT=587
MAIL_FROM_NAME=ABCMedical

Or by using quotes:

MAIL_PORT=587
MAIL_FROM_NAME="ABC Medical"
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! it resolved my issue. Anyway is there a way to add spaces in .env file?
@HiranD.AWalawage try wrapping the values in quotes.
2

I got this error when passing values with spaces in .env without quotes, I fixed it by wrapping the values in quotes.

Comments

0

have you try composer dump-autoload?

you might add a class without dump-autoload

1 Comment

@Waqleh This is cause by the code, find out where you has use the class log
0

Most common reasons I can think of for this error to occur are the following:

  1. Log class is called in a scope where it is not included with the USE statement.
  2. A config file contains (parse) errors, which in turn does not allow your application to find the Log class. Check the files loaded early on in Laravel such as app.php.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.