Google Cloud setup
This commit is contained in:
parent
10bf90bd93
commit
d84ab9412f
|
@ -37,6 +37,8 @@ class AppKernel extends Kernel
|
||||||
new \Snc\RedisBundle\SncRedisBundle(),
|
new \Snc\RedisBundle\SncRedisBundle(),
|
||||||
new \HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
|
new \HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
|
||||||
new \FOS\UserBundle\FOSUserBundle(),
|
new \FOS\UserBundle\FOSUserBundle(),
|
||||||
|
new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
|
||||||
|
new Vich\UploaderBundle\VichUploaderBundle(),
|
||||||
new Sikofitt\DoughnutWeddingBundle\SikofittDoughnutWeddingBundle(),
|
new Sikofitt\DoughnutWeddingBundle\SikofittDoughnutWeddingBundle(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ imports:
|
||||||
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||||
parameters:
|
parameters:
|
||||||
locale: en
|
locale: en
|
||||||
|
google.credentials_file: '%kernel.root_dir%/config/google-storage-key.json'
|
||||||
|
google.client_id: '100826355104373784827'
|
||||||
|
google.application_name: 'doughnut-wedding'
|
||||||
framework:
|
framework:
|
||||||
cache:
|
cache:
|
||||||
app: cache.adapter.redis
|
app: cache.adapter.redis
|
||||||
|
@ -118,9 +120,12 @@ doctrine_cache:
|
||||||
swiftmailer:
|
swiftmailer:
|
||||||
transport: '%mailer_transport%'
|
transport: '%mailer_transport%'
|
||||||
host: '%mailer_host%'
|
host: '%mailer_host%'
|
||||||
|
port: '%mailer_port%'
|
||||||
username: '%mailer_user%'
|
username: '%mailer_user%'
|
||||||
password: '%mailer_password%'
|
password: '%mailer_password%'
|
||||||
spool: { type: memory }
|
spool: { type: memory }
|
||||||
|
delivery_addresses: ['eric@rewiv.com']
|
||||||
|
sender_address: 'noreply@doughnutwedding.com'
|
||||||
|
|
||||||
hwi_oauth:
|
hwi_oauth:
|
||||||
firewall_names: [secured_area]
|
firewall_names: [secured_area]
|
||||||
|
@ -183,15 +188,20 @@ fos_user:
|
||||||
registration:
|
registration:
|
||||||
form:
|
form:
|
||||||
type: Sikofitt\DoughnutWeddingBundle\Form\RegistrationType
|
type: Sikofitt\DoughnutWeddingBundle\Form\RegistrationType
|
||||||
swiftmailer:
|
|
||||||
#disable_delivery: true
|
|
||||||
transport: null #'%mailer_transport%'
|
|
||||||
host: '%mailer_host%'
|
|
||||||
username: '%mailer_user%'
|
|
||||||
password: '%mailer_password%'
|
|
||||||
spool: { type: memory }
|
|
||||||
delivery_addresses: ['info@doughnutwedding.com']
|
|
||||||
sender_address: 'noreply@doughnutwedding.com'
|
|
||||||
|
|
||||||
|
knp_gaufrette:
|
||||||
|
adapters:
|
||||||
|
gallery:
|
||||||
|
google_cloud_storage:
|
||||||
|
service_id: 'doughnutwedding.google_cloud_storage.service'
|
||||||
|
bucket_name: 'zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4'
|
||||||
|
options:
|
||||||
|
acl: 'public'
|
||||||
|
filesystems:
|
||||||
|
cloud:
|
||||||
|
adapter: gallery
|
||||||
|
alias: google_cloud
|
||||||
|
vich_uploader:
|
||||||
|
db_driver: orm
|
||||||
sikofitt_doughnut_wedding:
|
sikofitt_doughnut_wedding:
|
||||||
max_rsvps: ~
|
max_rsvps: ~
|
|
@ -9,7 +9,7 @@ framework:
|
||||||
|
|
||||||
web_profiler:
|
web_profiler:
|
||||||
toolbar: true
|
toolbar: true
|
||||||
intercept_redirects: false
|
intercept_redirects: true
|
||||||
|
|
||||||
monolog:
|
monolog:
|
||||||
handlers:
|
handlers:
|
||||||
|
|
|
@ -14,6 +14,7 @@ parameters:
|
||||||
mailer_host: 127.0.0.1
|
mailer_host: 127.0.0.1
|
||||||
mailer_user: ~
|
mailer_user: ~
|
||||||
mailer_password: ~
|
mailer_password: ~
|
||||||
|
mailer_port: ~
|
||||||
|
|
||||||
# A secret key that's used to generate certain security-related tokens
|
# A secret key that's used to generate certain security-related tokens
|
||||||
secret: ThisTokenIsNotSoSecretChangeIt
|
secret: ThisTokenIsNotSoSecretChangeIt
|
||||||
|
|
|
@ -23,4 +23,9 @@ services:
|
||||||
arguments: ['@router']
|
arguments: ['@router']
|
||||||
tags:
|
tags:
|
||||||
- { name: kernel.event_listener, event: fos_user.registration.confirmed }
|
- { name: kernel.event_listener, event: fos_user.registration.confirmed }
|
||||||
- { name: kernel.event_listener, event: fos_user.registration.completed }
|
- { name: kernel.event_listener, event: fos_user.registration.completed }
|
||||||
|
doughnutwedding.google_cloud_storage.service:
|
||||||
|
class: \Google_Service_Storage
|
||||||
|
factory: ['Sikofitt\DoughnutWeddingBundle\Factory\GoogleCloudStorageServiceFactory', createGoogleCloudService]
|
||||||
|
arguments: ['%google.credentials_file%', '%google.client_id%', '%google.application_name%']
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,8 @@
|
||||||
"tedivm/stash": "^0.14.1",
|
"tedivm/stash": "^0.14.1",
|
||||||
"tedivm/stash-bundle": "^0.6.2",
|
"tedivm/stash-bundle": "^0.6.2",
|
||||||
"twig/extensions": "^1.4",
|
"twig/extensions": "^1.4",
|
||||||
"twig/twig": "^1.0||^2.0"
|
"twig/twig": "^1.0||^2.0",
|
||||||
|
"vich/uploader-bundle": "^1.5"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/doctrine-fixtures-bundle": "^2.3",
|
"doctrine/doctrine-fixtures-bundle": "^2.3",
|
||||||
|
|
|
@ -43,7 +43,6 @@ class DefaultController extends Controller
|
||||||
if (null !== $this->getUser()) {
|
if (null !== $this->getUser()) {
|
||||||
$parameters['hide_social'] = true;
|
$parameters['hide_social'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('default/index.html.twig', $parameters);
|
return $this->render('default/index.html.twig', $parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,10 @@ class ImageController extends Controller
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
return $this->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', [
|
/** @var \Gaufrette\Filesystem $fileSystem */
|
||||||
// ...
|
$fileSystem = $this->get('knp_gaufrette.filesystem_map')->get('cloud');
|
||||||
|
dump($fileSystem->listKeys());
|
||||||
|
return $this->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', [
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sikofitt\DoughnutWeddingBundle\Factory;
|
||||||
|
|
||||||
|
use Gaufrette\Exception\FileNotFound;
|
||||||
|
use Google\Auth\Credentials\ServiceAccountCredentials;
|
||||||
|
use Google_Service_Storage;
|
||||||
|
class GoogleCloudStorageServiceFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $credentialFile
|
||||||
|
* @param string $clientId
|
||||||
|
* @param string $applicationName
|
||||||
|
*
|
||||||
|
* @return \Google_Service_Storage
|
||||||
|
* @throws \ErrorException
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public static function createGoogleCloudService(string $credentialFile, string $clientId, string $applicationName) : \Google_Service_Storage
|
||||||
|
{
|
||||||
|
if(false === file_exists($credentialFile)) {
|
||||||
|
throw new \ErrorException(sprintf('File %s does not exist.', $credentialFile));
|
||||||
|
}
|
||||||
|
if(false === is_readable($credentialFile)) {
|
||||||
|
throw new \ErrorException(sprintf('File %s is not readable. Check permissions.', $credentialFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonStr = file_get_contents($credentialFile);
|
||||||
|
if( null === $credentials = json_decode($jsonStr, true)) {
|
||||||
|
throw new \ErrorException('Could not decode google json credentials');
|
||||||
|
}
|
||||||
|
|
||||||
|
$client = new \Google_Client();
|
||||||
|
$client->setClientId($clientId);
|
||||||
|
$client->setApplicationName($applicationName);
|
||||||
|
|
||||||
|
|
||||||
|
$cred = ServiceAccountCredentials::makeCredentials(
|
||||||
|
Google_Service_Storage::DEVSTORAGE_FULL_CONTROL,
|
||||||
|
$credentials
|
||||||
|
);
|
||||||
|
$token = $cred->fetchAuthToken();
|
||||||
|
$client->setAccessToken($token);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return new \Google_Service_Storage($client);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,13 +14,13 @@ if (!isset($_SERVER['HTTP_HOST'])) {
|
||||||
exit('This script cannot be run from the CLI. Run it from a browser.');
|
exit('This script cannot be run from the CLI. Run it from a browser.');
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
|
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
|
||||||
// '127.0.0.1',
|
'127.0.0.1',
|
||||||
// '::1',
|
'::1',
|
||||||
//))) {
|
))) {
|
||||||
// header('HTTP/1.0 403 Forbidden');
|
header('HTTP/1.0 403 Forbidden');
|
||||||
// exit('This script is only accessible from localhost.');
|
exit('This script is only accessible from localhost.');
|
||||||
//}
|
}
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
|
require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue