# Running PHP script after clone

**URL:** <https://discuss.bitrise.io/t/running-php-script-after-clone/5934>\
**Category:** Question & Answer\
**Tags:** workflow, script\
**Created:** [August 15, 2018, 2:57pm UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934 "2018-08-15T14:57:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehuda](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@ehuda](https://discuss.bitrise.io/u/ehuda)\
**Post date:** [August 15, 2018, 2:57pm UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/1 "2018-08-15T14:57:01Z")

</div>

It seems like it should be easy to run a script after Bitrise clones your repo but I can’t seem to get it to work with PHP.

My file is located at /poster.php. It takes 2 command line arg. Tag and API KEY. The API\_KEY is stored in a secret.

So i’ve tried:

**Script-Runner**

```auto
$BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY

```

With config set to:  
Execute with / runner binary: `php`

**Do anything with script step**

```auto
#!/usr/bin/php
# fail if any commands fails
set -e
# debug log
set -x

# write your script here
echo "Bitrise... Building..."

php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY

```

**Errors:**

_php: command not found_ (Do anything with script step)

_file\_path: path not exist at: /bitrise/src/poster.php_ (Script-runner)

Not sure how to get this thing working, any help is appriciated

---

<div class="post-metadata">

**Author:** ![ehuda](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@ehuda](https://discuss.bitrise.io/u/ehuda)\
**Post date:** [August 15, 2018, 3:43pm UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/2 "2018-08-15T15:43:22Z")

</div>

Switching to Xcode instead of Ubunto did the trick!

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [August 16, 2018, 8:57am UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/3 "2018-08-16T08:57:29Z")

</div>

Hey @ehuda!

Glad to hear you solved the issue! Thanks for leaving it here, I’m sure it will help others stumbling into similar ones 🙂

---

<div class="post-metadata">

**Author:** ![ehuda](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@ehuda](https://discuss.bitrise.io/u/ehuda)\
**Post date:** [August 21, 2018, 2:25am UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/4 "2018-08-21T02:25:15Z")

</div>

@bitce I’m actually getting stuck again. Any chance you could help out?

```
---
format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- pull_request_source_branch: "*"
  workflow: primary
- tag: "*"
  workflow: primary
workflows:
  primary:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.11: {}
    - script-runner@0.9.3:
        inputs:
        - runner: php
        - is_debug: 'yes'
        - file_path: "$BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE"
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - is_debug: 'yes'
        - runner_bin: php
        - content: |-
            #!/usr/bin/php
            # fail if any commands fails
            set -e
            # debug log
            set -x

            php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE
        is_always_run: true
    - deploy-to-bitrise-io@1.3.12: {}

```

I understand that script-runner wont work because i’m trying to add command line argument to the file path but I don’t understand why the script@1.1.5 wont work.

It says it ended successfully but the script doesn’t seem to have run. Are the env variables not getting converted?

How would I properly run this code? Just to recap. I have a php script in my github repo. Im trying to call it using:

`php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE`

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [August 21, 2018, 8:07am UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/5 "2018-08-21T08:07:03Z")

</div>

Hey @ehuda!

Can you send us the URL to the build please so we can see everything that’s going on in there?

---

<div class="post-metadata">

**Author:** ![adamdave12](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@adamdave12](https://discuss.bitrise.io/u/adamdave12)\
**Post date:** [August 22, 2018, 12:36am UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/6 "2018-08-22T00:36:35Z")

</div>

If you are facing some kind of process to generate the entire knowledge regarding the process to setup the installation of the PHP can be better if you get the process from the help of the [Google Drive Support](https://googlesupport.co/google-drive-support/) to generate the entire process for the knowledge.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/d/d901cf2aad020f2dd11918afc89ec2089bb87b35.png) [@system](https://discuss.bitrise.io/u/system)\
**Post date:** [September 21, 2018, 12:48am UTC](https://discuss.bitrise.io/t/running-php-script-after-clone/5934/7 "2018-09-21T00:48:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
