Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting last commit's zip with php
    primarykey
    data
    text
    <p>I found the code below for automated deploying php project. The problem is "https://bitbucket.org/$username/$reponame/get/tip.zip" this url doesnt work on private git repo on bitbucket private git repo: probably related with authentication (I haven't tested this on public repo) What i need is to get the last commit's zip file and unzip inside my project. What am i missing? How to fix this issue <pre><code>// your Bitbucket username $username = "edifreak"; // your Bitbucket repo name $reponame = "canvas-game-demo"; // extract to $dest = "./"; // leave ./ for relative destination //////////////////////////////////////////////////////// // Let's get stuff done! // set higher script timeout (for large repo's or slow servers) set_time_limit(380); // download the repo zip file $repofile = file_get_contents("https://bitbucket.org/$username/$reponame/get/tip.zip"); file_put_contents('tip.zip', $repofile); unset($repofile); // unzip $zip = new ZipArchive; $res = $zip-&gt;open('tip.zip'); if ($res === TRUE) { $zip-&gt;extractTo('./'); $zip-&gt;close(); } else { die('ZIP not supported on this server!'); } // delete unnecessary .hg files @unlink("$username-$reponame-tip/.hgignore"); @unlink("$username-$reponame-tip/.hg_archival.txt"); // function to delete all files in a directory recursively function rmdir_recursively($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." &amp;&amp; $object != "..") { if (filetype($dir."/".$object) == "dir") rmdir_recursively($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } // function to recursively copy the files function copy_recursively($src, $dest) { if (is_dir($src)) { if($dest != "./") rmdir_recursively($dest); @mkdir($dest); $files = scandir($src); foreach ($files as $file) if ($file != "." &amp;&amp; $file != "..") copy_recursively("$src/$file", "$dest/$file"); } else if (file_exists($src)) copy($src, $dest); rmdir_recursively($src); } // start copying the files from extracted repo and delete the old directory recursively copy_recursively("$username-$reponame-tip", $dest); // delete the repo zip file unlink("tip.zip"); // Yep, we're done :) echo "We're done!"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload