Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runnable as cloud foundry app and fix basic auth with php fcgi
- Loading branch information
Showing
27 changed files
with
862 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"WEBDIR": "app", | ||
"COMPOSER_VENDOR_DIR": "vendor" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.phar | ||
/.idea | ||
logs | ||
/cache | ||
/tests | ||
/.scrutinizer.yml | ||
/.gitattributes | ||
/.travis.yml | ||
/phpunit.xml.dist | ||
/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
/tests export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.gitattributes export-ignore | ||
/.travis.yml export-ignore | ||
/apigen.neon export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/screen.png export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ vendor | |
*.phar | ||
/.idea | ||
logs | ||
/cache/service-broker.sqlite | ||
/cache/service-broker.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
#Generated manifest | ||
applications: | ||
- name: php-cf-service-broker | ||
memory: 1G | ||
instances: 1 | ||
path: ./ | ||
host: php-cf-service-broker | ||
# Bind your database | ||
#services: | ||
# - test-sb-php | ||
buildpack: https://github.com/cloudfoundry/php-buildpack.git # cause we need composer alpha10 and current php_buildpack on run.pivotal.io is not up-to-date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/Sphring/MicroWebFramework/CloudFoundry/CloudFoundry.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Copyright (C) 2015 Arthur Halet | ||
* | ||
* This software is distributed under the terms and conditions of the 'MIT' | ||
* license which can be found in the file 'LICENSE' in this package distribution | ||
* or at 'http://opensource.org/licenses/MIT'. | ||
* | ||
* Author: Arthur Halet | ||
* Date: 12/05/2015 | ||
*/ | ||
|
||
|
||
namespace Sphring\MicroWebFramework\CloudFoundry; | ||
|
||
|
||
use Arhframe\Util\File; | ||
use CfCommunity\CfHelper\CfHelper; | ||
use Doctrine\Common\Cache\FilesystemCache; | ||
|
||
class CloudFoundry | ||
{ | ||
/** | ||
* @var CfHelper | ||
*/ | ||
private $cfHelper; | ||
|
||
public function __construct() | ||
{ | ||
$this->cfHelper = CfHelper::getInstance(); | ||
} | ||
|
||
public function getDatabaseUrl() | ||
{ | ||
if (!$this->isInCloudFoundry()) { | ||
return null; | ||
} | ||
$dbConnector = $this->cfHelper->getDatabaseConnector(); | ||
$dbConnector->load(); | ||
$credentials = $dbConnector->getCredentials(); | ||
if ($credentials === null) { | ||
return null; | ||
} | ||
$port = null; | ||
if (isset($credentials['port'])) { | ||
$port = ":" . $credentials['port']; | ||
} | ||
$password = null; | ||
if (isset($credentials['pass'])) { | ||
$password = ":" . $credentials['pass']; | ||
} | ||
return $credentials['type'] . "://" . $credentials['user'] | ||
. $password . '@' . $credentials['host'] . $port . '/' . $credentials['database']; | ||
} | ||
|
||
public function isInCloudFoundry() | ||
{ | ||
return $this->cfHelper->isInCloudFoundry(); | ||
} | ||
|
||
public function getDoctrineCache() | ||
{ | ||
if (!$this->isInCloudFoundry()) { | ||
return null; | ||
} | ||
return new FilesystemCache(sys_get_temp_dir()); | ||
} | ||
|
||
public function getFolderCache() | ||
{ | ||
if (!$this->isInCloudFoundry()) { | ||
return null; | ||
} | ||
return sys_get_temp_dir(); | ||
} | ||
|
||
public function getFileCreation() | ||
{ | ||
if (!$this->isInCloudFoundry()) { | ||
return null; | ||
} | ||
$file = new File(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'db.ct'); | ||
$file->createFolder(); | ||
if (!$file->isFile()) { | ||
$file->setContent(0); | ||
} | ||
return $file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.