First commit

This commit is contained in:
R. Eric Wheeler 2016-11-17 18:32:13 -08:00
commit 3611104c8c
9 changed files with 800 additions and 0 deletions

3
.bowerrc Normal file
View File

@ -0,0 +1,3 @@
{
"directory":"vendor/"
}

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea/
vendor/
composer.lock

21
bower.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "sikofitt/php-version",
"authors": [
"sikofitt <sikofitt@gmail.com>"
],
"description": "Pulls version information from qa.php.net/api.php",
"main": "",
"license": "GPL-3.0",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"uikit": "^2.27.2"
}
}

24
composer.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "sikofitt/php-version",
"description": "Pulls version information from qa.php.net/api.php",
"type": "project",
"autoload": {
"psr-4": {
"Sikofitt\\":"src/Sikofitt"
}
},
"require": {
"php": ">=7.0.0",
"guzzlehttp/guzzle": "^6.2",
"webmozart/json": "^1.2",
"doctrine/collections": "^1.3",
"twig/twig": "^1.28"
},
"license": "GPL-3.0",
"authors": [
{
"name": "sikofitt",
"email": "sikofitt@gmail.com"
}
]
}

54
index.html.twig Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Recent Version of PHP</title>
<link rel="stylesheet" type="text/css" href="vendor/uikit/css/uikit.almost-flat.min.css"/>
<style type="text/css">
.uk-modal-content h3 {
word-wrap: break-word;
word-break: break-all;
}
</style>
</head>
<body>
<div class="uk-container uk-container-center uk-margin-large-top uk-margin-large-bottom">
<h1 class="uk-text-center uk-text-primary">Recent RC Version of PHP</h1>
{% if release is null %}
<div class="uk-width-1-1">
<h3>No RC Releases Found.</h3>
</div>
{% else %}
<div class="uk-width-1-1">
{% set fullVersion = release.version ~ release.release.type ~ release.release.number %}
<h3 class="uk-align-medium-left">{{ fullVersion }}</h3>
<div class="uk-grid uk-grid-large">
{% for file in release.release.files %}
<div class="uk-width-1-3">
<div class="uk-panel uk-panel-box uk-grid">
<div class="uk-panel-badge uk-badge">{{ file.type|upper }}</div>
<h3 class="uk-panel-title">php-{{ fullVersion }}.tar.{{ file.type }}</h3>
<div class="uk-width-1-1 uk-grid">
<div class="uk-width-1-3">
<a href="{{ file.path }}" title="{{ file.type|upper }}">Download</a>
</div>
<div class="uk-width-1-3">
<a href="javascript:;;" onclick="UIkit.modal.alert('<h3>{{ file.md5 }}<?h3>');">MD5</a>
</div>
<div class="uk-width-1-3">
<a href="javascript:;;" onclick="UIkit.modal.alert('<h3>{{ file.sha256 }}</h3>');">SHA256</a></div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
<script type="text/javascript" src="vendor/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="vendor/uikit/js/uikit.min.js"></script>
</body>
</html>

110
index.php Normal file
View File

@ -0,0 +1,110 @@
<?php
/**
* This is a stupid php thing to pull the most recent releases
* from qa.php.net/api.php
*/
require 'vendor/autoload.php';
use Doctrine\Common\Collections\ArrayCollection;
use GuzzleHttp\Client;
use Sikofitt\PhpVersion\Entity\{
FileInfo, ReleaseInfo, VersionInfo
};
use Webmozart\Json\JsonDecoder;
$client = new Client(
[
'base_uri' => 'https://qa.php.net/api.php',
]
);
$result = $client->get(
'',
[
'query' => [
'type' => 'qa-releases',
'format' => 'json',
],
]
);
$contents = $result
->getBody()
->getContents();
$json = new JsonDecoder();
$decoded = $json->decode($contents);
$releases = new ArrayCollection();
foreach ($decoded as $key => $value) {
if ('releases' === $key || 'reported' === $key) {
continue;
}
$versionInfo = new VersionInfo();
$versionInfo
->setActive($value->active)
->setDevVersion($value->dev_version)
->setVersion($key);
$info = new ReleaseInfo();
$info->setType($value->release->type)
->setNumber($value->release->number)
->setVersion(isset($value->release->version) ?? "")
->setMd5Bz2($value->release->md5_bz2)
->setMd5Gz($value->release->md5_gz)
->setMd5Xz($value->release->md5_xz)
->setSha256Bz2($value->release->sha256_bz2)
->setSha256Gz($value->release->sha256_gz)
->setSha256Xz($value->release->sha256_xz)
->setDate($value->release->date)
->setBaseUrl($value->release->baseurl);
if (isset($value->release->files)) {
foreach ($value->release->files as $fileKey => $fileValue) {
$file = new FileInfo();
$file->setType($fileKey)
->setMd5($fileValue->md5)
->setSha256($fileValue->sha256)
->setPath($fileValue->path);
$info->addFile($file);
}
}
$versionInfo->setRelease($info);
$releases->set($versionInfo->getVersion(), $versionInfo);
}
$twig = new Twig_Environment(
new Twig_Loader_Filesystem([ __DIR__])
);
$releases = $releases->filter(
function (VersionInfo $version) {
return 0 !== $version->getRelease()->getNumber();
}
);
if(false === $releases->isEmpty()) {
foreach ($releases as $release)
{
$twig->display('index.html.twig', ['release' => $release]);
}
} else {
$twig->display('index.html.twig', ['release' => null]);
}

View File

@ -0,0 +1,117 @@
<?php
/**
* This is a stupid php thing to pull the most recent releases
* from qa.php.net/api.php
*/
namespace Sikofitt\PhpVersion\Entity;
/**
* Class FileInfo
*
* @package Sikofitt\PhpVersion\Entity
*/
class FileInfo
{
/**
* @var string
*/
private $type;
/**
* @var string
*/
private $path;
/**
* @var string
*/
private $md5;
/**
* @var string
*/
private $sha256;
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*
* @return FileInfo
*/
public function setType(string $type): FileInfo
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}
/**
* @param string $path
*
* @return FileInfo
*/
public function setPath(string $path): FileInfo
{
$this->path = $path;
return $this;
}
/**
* @return string
*/
public function getMd5(): string
{
return $this->md5;
}
/**
* @param string $md5
*
* @return FileInfo
*/
public function setMd5(string $md5): FileInfo
{
$this->md5 = $md5;
return $this;
}
/**
* @return string
*/
public function getSha256(): string
{
return $this->sha256;
}
/**
* @param string $sha256
*
* @return FileInfo
*/
public function setSha256(string $sha256): FileInfo
{
$this->sha256 = $sha256;
return $this;
}
}

View File

@ -0,0 +1,349 @@
<?php
/**
* This is a stupid php thing to pull the most recent releases
* from qa.php.net/api.php
*/
namespace Sikofitt\PhpVersion\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Class ReleaseInfo
*
* @package Sikofitt\PhpVersion\Entity
*/
class ReleaseInfo
{
/**
* @var string
*/
private $type;
/**
* @var int
*/
private $number;
/**
* @var string
*/
private $md5Bz2;
/**
* @var string
*/
private $md5Gz;
/**
* @var string
*/
private $md5Xz;
/**
* @var string
*/
private $sha256Bz2;
/**
* @var string
*/
private $sha256Gz;
/**
* @var string
*/
private $sha256Xz;
/**
* @var string
*/
private $date;
/**
* @var string
*/
private $baseUrl;
/**
* @var string
*/
private $version;
/**
* @var ArrayCollection
*/
private $files;
public function __construct()
{
$this->files = new ArrayCollection();
}
/**
* @return string
*/
public function getType() : String
{
return $this->type;
}
/**
* @param string $type
*
* @return ReleaseInfo
*/
public function setType(String $type) : ReleaseInfo
{
$this->type = $type;
return $this;
}
/**
* @return int
*/
public function getNumber() : Int
{
return $this->number;
}
/**
* @param int $number
*
* @return ReleaseInfo
*/
public function setNumber(Int $number) : ReleaseInfo
{
$this->number = $number;
return $this;
}
/**
* @return string
*/
public function getMd5Bz2() : String
{
return $this->md5Bz2;
}
/**
* @param string $md5Bz2
*
* @return ReleaseInfo
*/
public function setMd5Bz2(String $md5Bz2) : ReleaseInfo
{
$this->md5Bz2 = $md5Bz2;
return $this;
}
/**
* @return string
*/
public function getMd5Gz() : String
{
return $this->md5Gz;
}
/**
* @param string $md5Gz
*
* @return ReleaseInfo
*/
public function setMd5Gz(String $md5Gz) : ReleaseInfo
{
$this->md5Gz = $md5Gz;
return $this;
}
/**
* @return string
*/
public function getMd5Xz() : String
{
return $this->md5Xz;
}
/**
* @param string $md5Xz
*
* @return ReleaseInfo
*/
public function setMd5Xz(String $md5Xz)
{
$this->md5Xz = $md5Xz;
return $this;
}
/**
* @return string
*/
public function getSha256Bz2() : String
{
return $this->sha256Bz2;
}
/**
* @param string $sha256Bz2
*
* @return ReleaseInfo
*/
public function setSha256Bz2(String $sha256Bz2) : ReleaseInfo
{
$this->sha256Bz2 = $sha256Bz2;
return $this;
}
/**
* @return string
*/
public function getSha256Gz() : String
{
return $this->sha256Gz;
}
/**
* @param string $sha256Gz
*
* @return ReleaseInfo
*/
public function setSha256Gz(String $sha256Gz) : ReleaseInfo
{
$this->sha256Gz = $sha256Gz;
return $this;
}
/**
* @return string
*/
public function getSha256Xz() : String
{
return $this->sha256Xz;
}
/**
* @param string $sha256Xz
*
* @return ReleaseInfo
*/
public function setSha256Xz(String $sha256Xz) : ReleaseInfo
{
$this->sha256Xz = $sha256Xz;
return $this;
}
/**
* @return string
*/
public function getDate() : String
{
return $this->date;
}
/**
* @param string $date
*
* @return ReleaseInfo
*/
public function setDate(String $date) : ReleaseInfo
{
$this->date = $date;
return $this;
}
/**
* @return string
*/
public function getBaseUrl() : String
{
return $this->baseUrl;
}
/**
* @param string $baseUrl
*
* @return ReleaseInfo
*/
public function setBaseUrl(String $baseUrl) : ReleaseInfo
{
$this->baseUrl = $baseUrl;
return $this;
}
/**
* @return string
*/
public function getVersion() : String
{
return $this->version;
}
/**
* @param string $version
*
* @return ReleaseInfo
*/
public function setVersion(String $version) : ReleaseInfo
{
$this->version = $version;
return $this;
}
/**
* @return ArrayCollection
*/
public function getFiles() : ArrayCollection
{
return $this->files;
}
/**
* @param ArrayCollection $files
*
* @return ReleaseInfo
*/
public function setFiles(ArrayCollection $files)
{
$this->files = $files;
return $this;
}
/**
* @param \Sikofitt\PhpVersion\Entity\FileInfo $file
*
* @return ReleaseInfo
*/
public function addFile(FileInfo $file) : ReleaseInfo
{
$this->files->add($file);
return $this;
}
/**
* @param \Sikofitt\PhpVersion\Entity\FileInfo $file
*
* @return ReleaseInfo
*/
public function removeFile(FileInfo $file) : ReleaseInfo
{
$this->files->removeElement($file);
return $this;
}
}

View File

@ -0,0 +1,119 @@
<?php
/**
* This is a stupid php thing to pull the most recent releases
* from qa.php.net/api.php
*/
namespace Sikofitt\PhpVersion\Entity;
/**
* Class VersionInfo
*
* @package Sikofitt\PhpVersion\Entity
*/
class VersionInfo
{
/**
* @var string
*/
private $version;
/**
* @var bool
*/
private $active = false;
/**
* @var ReleaseInfo
*/
private $release;
/**
* @var string
*/
private $devVersion;
/**
* @return string
*/
public function getVersion(): string
{
return $this->version;
}
/**
* @param string $version
*
* @return VersionInfo
*/
public function setVersion(string $version): VersionInfo
{
$this->version = $version;
return $this;
}
/**
* @return boolean
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param boolean $active
*
* @return VersionInfo
*/
public function setActive(bool $active): VersionInfo
{
$this->active = $active;
return $this;
}
/**
* @return ReleaseInfo
*/
public function getRelease(): ReleaseInfo
{
return $this->release;
}
/**
* @param ReleaseInfo $release
*
* @return VersionInfo
*/
public function setRelease(ReleaseInfo $release): VersionInfo
{
$this->release = $release;
return $this;
}
/**
* @return string
*/
public function getDevVersion(): string
{
return $this->devVersion;
}
/**
* @param string $devVersion
*
* @return VersionInfo
*/
public function setDevVersion(string $devVersion): VersionInfo
{
$this->devVersion = $devVersion;
return $this;
}
}