Composer无法运行安装后脚本

时间:2015-11-05 16:43:23

标签: bash composer-php

尝试在Composer安装后/更新挂钩中运行bash脚本时出现以下错误:

> post-install.sh
sh: 1: post-install.sh: not found
Script post-install.sh handling the post-install-cmd event returned with an error



  [RuntimeException]
  Error Output: sh: 1: post-install.sh: not found

原创作曲家.json

有效,但更新post install / update命令以便在两个地方运行会很烦人。

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ...
    ...
  },
  "scripts": {
    "post-install-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ],
    "post-update-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ]
  }
}

根据Composer documentation

  

用Composer的术语表示,脚本可以是PHP回调(已定义)   作为静态方法)或任何命令行可执行命令。

所以我的composer.json应该可以这样工作:

通缉composer.json

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ...
    ...
  },
  "scripts": {
    "post-install-cmd": [
      "post-install.sh"
    ],
    "post-update-cmd": [
      "post-install.sh"
    ]
  }
}

post-install.sh

每个人都可执行(0775)并且与composer.json位于同一目录

#!/bin/bash

mkdir -p _libraries
cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/
...
...

2 个答案:

答案 0 :(得分:10)

实现单一任务定义的其他方法是referencing scripts

string get_amt = dt_.Rows[i]["billing_amt"].ToString();

答案 1 :(得分:9)

comments我建议使用

// To connect with a subdomain - the entry will be in config/database.php.
public static function connectSubdomainDatabase()
{
    // Break apart host
    $urlParts = explode('.', $_SERVER['HTTP_HOST']);

    // Change default connection
    Config::set('database.default', $urlParts[0]);
 }

这似乎有效。