hello,

J'essaye de créer un zip github à partir d'un sous répertoire.
je suis capable de récupérer les sous réptoires d'un repo github mais comment créer un zip de ce sous répertoire et l'insérer dans un répertoire du serveur.
Objectif, créer un système de mise en place à de plug in à partir de github

J'ai vu plus contribution mais qui utilise le composer et cela m'intéresse car trop complète et comportant des librairies inutile dans mon cas.

Voici ce que j'ai fait. Cela liste des sous répertoire d'un repo github, reste le bouton install qui doit déclencher la création d'un zip d'un sous répertoire et l'insérer dans un répertoire du serveur web.

Merci.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
          $content_module = array();
          $result = array();
          $github_url = 'https://api.github.com/repos/MyRepoName/MyRepoModules/';
 
  $context = stream_context_create(array('http' => array(
                                                        'header' => 'User-Agent: ClicShopping',
                                                        )
                                         )
                                  );
 
  $json = file_get_contents($github_url . 'contents/', true, $context );
  $result = json_decode($json);
  $result = json_decode($json);
        //echo '<pre>'.print_r($result,true) .'</pre>';
 ?>
        <!DOCTYPE html>
        <html dir="ltr" lang="fr">
        <head>
          <meta charset="UTF-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" />
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
 
          <script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous"></script>
          <script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
 
        </head>
        <body>
          <table width="100%">
            <tr>
              <td with="5%" class="text-md-center"></td>
              <td with="33%" class="text-md-center">Module Name</td>
              <td with="33%" class="text-md-center">Module Description</td>
              <td with="33%" class="text-md-center">Installation</td>
            </tr>
<?php
// content of repository ClicShopping_v3_official_modules
 
  for ($i=0, $n=sizeof($result); $i<$n; $i++) {
    echo '<tr>';
 
    if ($result[$i]->name != 'LICENSE' && $result[$i]->name != 'README.md') {
      $module_name = $result[$i]->name;
      $module_sha = $result[$i]->sha;
      echo '<td>image</td>';
      echo '<td>' . $module_name . '</td>';
    }
 
 
// list information repo
    $json1 = file_get_contents($github_url . 'contents/' . $module_name, true, $context);
    $result1 = json_decode($json1);
 
    foreach ($result1 as $content) {
 
      $content_module_name = $content->name;
 
      if ($content_module_name == $module_name . '.json') {
 
        $content_module = file_get_contents($content->download_url, true); //content of readme.
        $result_content_module = json_decode($content_module);
 
//        echo '<pre>' . print_r($result_content_module, true) . '</pre>';
 
        echo '<td>';
        echo '<br />' . $result_content_module->description;
        echo '<br />Concepteur  : ' . $result_content_module->vendor;
        echo '<br />Licence  : ' . $result_content_module->license;
        echo '<br />version : ' . $result_content_module->version;
        echo '<br />tag : ' . $result_content_module->tag;
        echo '</td>';
        echo '<td><button type="button" class="btn btn-default" git-name="' . $content_module_name . '"> <a href="' . $github_url . 'git/trees/' . $module_sha . '" git-type="cell" onclick="zipItButtonClick(this); >"><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Module Install</a></button></td>';
 
      }
    }
    echo '</tr>';
  }
?>
              </tr>
            </table>
          </body>
        </html>