0

i am deploying my PHP application to the Microsoft Azure platform. On deploy it runs composer install and it has problems with the backslashes in windows: for every single class in the project and the libraries, it parses the file both with / and \ as path separator. Tens of thounsands of errors of this kind show up:

Warning: Ambigous class resolution. "SomeClass" was found in both
"D:/home/site/wwwroot/vendor/somevendeor/somelib/src/SomeClass.php" and 
"D:\home\site\wwwroot\vendor\somevendeor\somelib\src\SomeClass.php"

Parsing every file twice and printing all the errors over the network takes so long that Azure cancels the composer process. The deployment fails 9 of 10 times (leaves the application in an invalid, not-functioning state).

Does anyone know what can be done about this? I´d appreciate every hint! Thanks :)

EDIT: This is my composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "require": {
        "laravel/framework": "4.2.*",       
        "cartalyst/sentry": "2.0.*",
        "facebook/php-sdk-v4": "4.0.*",
        "thetwelvelabs/foursquare": "dev-master@dev",
        "hybridauth/hybridauth": "*",
        "caouecs/laravel4-lang": "*",
        "phpoffice/phpexcel": "*",
        "google/apiclient": "*"
    },
    "autoload": {
        ...
    },
    "scripts": {
        ...
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev"
}

EDIT 2: And this is my deploy.sh (executed after the push to the Repo on Azure has succeeded):

#!/bin/bash

# ----------------------
# KUDU Deployment Script
# Version: 0.2.2
# ----------------------

# Helpers
# -------

exitWithMessageOnError () {
  if [ ! $? -eq 0 ]; then
    echo "An error has occurred during web site deployment."
    echo $1
    exit 1
  fi
}

# Prerequisites
# -------------

# Verify node.js installed
hash node 2>/dev/null
exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment."

# Setup
# -----

SCRIPT_DIR="${BASH_SOURCE[0]%\\*}"
SCRIPT_DIR="${SCRIPT_DIR%/*}"
ARTIFACTS=$SCRIPT_DIR/../artifacts
KUDU_SYNC_CMD=${KUDU_SYNC_CMD//\"}

if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then
  DEPLOYMENT_SOURCE=$SCRIPT_DIR
fi

if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then
  NEXT_MANIFEST_PATH=$ARTIFACTS/manifest

  if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then
    PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH
  fi
fi

if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then
  DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot
else
  KUDU_SERVICE=true
fi

if [[ ! -n "$KUDU_SYNC_CMD" ]]; then
  # Install kudu sync
  echo Installing Kudu Sync
  npm install kudusync -g --silent
  exitWithMessageOnError "npm failed"

  if [[ ! -n "$KUDU_SERVICE" ]]; then
    # In case we are running locally this is the correct location of kuduSync
    KUDU_SYNC_CMD=kuduSync
  else
    # In case we are running on kudu service this is the correct location of kuduSync
    KUDU_SYNC_CMD=$APPDATA/npm/node_modules/kuduSync/bin/kuduSync
  fi
fi

##################################################################################################################################
# Download Composer
# ----------
echo Downloading Composer
curl -sS https://getcomposer.org/installer | php

##################################################################################################################################
# Deployment
# ----------

echo "Switching to Maintenance Mode"

cd $DEPLOYMENT_TARGET
php artisan down
exitWithMessageOnError "Failed to turn maintenance on (php artisan down)"

echo Handling Basic Web Site deployment.

# 1. KuduSync
if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then
  "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
  exitWithMessageOnError "Kudu Sync failed"
fi

##################################################################################################################################
# Dependency install
# ----------
# Invoke Composer in the deployment directory

echo Invoking composer install in deployment directory $DEPLOYMENT_TARGET
cd $DEPLOYMENT_TARGET
php $DEPLOYMENT_TARGET/composer.phar install -v --prefer-dist --no-dev --optimize-autoloader --no-interaction

echo Deleting all active Sessions
rm -f $DEPLOYMENT_TARGET/app/storage/sessions/*
echo Deleted all active Sessions

echo Clearing the cache
rm -f $DEPLOYMENT_TARGET/app/storage/cache/*
echo Cache Cleared

##################################################################################################################################

# Post deployment stub
if [[ -n "$POST_DEPLOYMENT_ACTION" ]]; then
  POST_DEPLOYMENT_ACTION=${POST_DEPLOYMENT_ACTION//\"}
  cd "${POST_DEPLOYMENT_ACTION_DIR%\\*}"
  "$POST_DEPLOYMENT_ACTION"
  exitWithMessageOnError "post deployment action failed"
fi

echo "Turning off Maintenance Mode"

cd $DEPLOYMENT_TARGET
php artisan up
exitWithMessageOnError "Failed to turn maintenance off (php artisan up)"

echo "Finished successfully."
marstato
  • 363
  • 2
  • 12
  • Can you show your `composer.json` file - preferrably a short one with only one library added, that still demonstrates the problem. – Sven Jun 29 '15 at 12:44
  • The problem does not occur when i execute `composer -o dump-autoload` manually via shell after a deployment. The composer.json contains libraries and a few autoload-directories, nothing more special. I dont think it is related to the problem. – marstato Jun 29 '15 at 12:55
  • Does that mean you won't provide data to demonstrate the problem? If this is a bug in Composer that incorrectly handles Windows paths, it should be fixed there. – Sven Jun 29 '15 at 13:01
  • No, i just did not think that it acutally matters. I suspect the problem with the host machine (on my machine, everything is fine, too). But i included the composer.json – marstato Jun 29 '15 at 13:42
  • And what is the command you call to trigger the error during deployment? – Sven Jun 29 '15 at 14:54
  • `php composer.phar install -v --prefer-dist --no-dev --optimize-autoloader --no-interaction` – marstato Jun 29 '15 at 15:34
  • I was unable to reproduce the error with the information. I suspect it could be related to some wrong directory separator, but without being able to reproduce it, this is only guessing. – Sven Jun 29 '15 at 16:52
  • I am trying to reproduce the issue on my side via following the steps mentioned at: http://blog.syntaxc4.net/post/2015/04/10/composer-support-for-azure-app-service-web-app-via-site-extension.aspx, however it seems working fine on my side, I can successfully enable a site extension in an Azure web app. Is this possible to have your repro steps so that we can look into the issue together? – Ming Xu - MSFT Jun 30 '15 at 10:56
  • I added my deploy.sh (executed after successful push to the Repo); The composer.json and the deploy.sh are the only thing that i set up for the automated deployment - the rest is a plain azure web-app. – marstato Jun 30 '15 at 12:32
  • We will try to reproduce the issue, meanwhile, I came across below post to hide that ambiguous class resolution warnings, I wonder if you are using newer version of composer? http://stackoverflow.com/questions/23316761/suppress-ambiguous-class-resolution-warning-on-composer-dump-autoload-o – Ming Xu - MSFT Jul 01 '15 at 09:05

1 Answers1

0

I tried a git deployment using details you have provided. It worked for me with below changes

Your deployment script has reference to artisan file. i had to remove below lines

deploy.sh

   php artisan down
   php artisan up

I dont have your scripts/autoload details in package.json

  "autoload": {
        ...
    },
    "scripts": {
        ...
    },

Look into above config changes and check if that resolves your issue.

prashanth
  • 131
  • 2
  • 3
  • 11