Runtime Exception: unable to create cache directory Google App Engine Symfony2 - php

I am working with google's app engine Symfony HelloWorld example from https://cloud.google.com/appengine/docs/php/symfony-hello-world with source taken from Github.
I have the basic case working, but when I update the AppKernal for a production release I get a fatal error in cloudstorage. The only change is in app.php from $kernel = new AppKernel(); to $kernel = new AppKernel('prod', true);
This produces the error
Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to create the cache directory (gs://symfony-sp-bucket15//symfony/cache) ' in /base/data/home/apps/s~symfony-starter-project/15.390142223904071434/app/bootstrap.php.cache:2632
I have tried clearing the cache and memcache. I've also consulted related links such as: RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev), but these do not resolve the issue on Google's App Engine. Any suggestions would be great.

Since GCS is emulated when you are testing locally, you should check if 'symfony-sp-bucket15' actually exists in your project (Storage -> Browser in the Developers Console). You may need to create it or specify a different bucket name in your config.

Related

Getting started with Google Storage

I am having really difficult time trying to connect Google Storage. All I need is to be able to upload PDF file to a bucket that I've created on Google Storage Console. The documentation seems to be all over the place and lacking simple examples of PHP code. So here's what I've done so far:
Installed cloud storage
$ composer require google/cloud-storage
Added billing as per Google's requirement. Enabled Cloud Storage API. Created project and added a bucket.
Attempted to use the following example:
require '../vendor/autoload.php';
define("PROJECT_ID", "my-project");
define("BUCKET_NAME", "my-bucket");
$client = new Google_Client();
$client->setApplicationName("API_Cloud_Storage");
$client->useApplicationDefaultCredentials();
$client->setScopes(["https://www.googleapis.com/auth/cloud-platform"]);
$service = new Google_Service_Storage($client);
$request = $service->buckets->listBuckets(PROJECT_ID);
foreach ($request["items"] as $bucket)
printf("%s\n", $bucket->getName());
Keep on getting error on
Fatal error: Uncaught Error: Class 'Google_Client' not found in /home/domain/public_html/test.php:11 ...
I know the vendor/autoload.php file is loading because I have no issues with AWS in a different script.
I didn't even pass the first line. What am I missing?
You have the documentation page for Cloud Storage Client Libraries with a PHP sample and detailed instructions. There's also a link to the GitHub repo for that quickstart, in addition to the one shared by ceejayoz in the comments.

Twig_Error_Loader exception caught when looking for a repository

I have to work on a project that my internship supervisor made on windows. He's making the backend and I'm making the frontend, but I need the backend to deal with the frontend of project.
I'm using XAMPP, and my Document Root is in /home/remy/www.
When I put in the URL localhost/Salto, it finds it rather easily. However, when I click on the web link that it shows to me, I get this error:
Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'The
"/home/remy/www/Salto\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle/Resources/views"
directory does not exist
("/home/remy/www/Salto\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle/Resources/views").
Some other things that are in the filesystem.php in the core and where the error is :
/home/remy/www/Salto/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 101.
I was asking myself if it could be with the \ in Windows (OS of my internship supervisor) and the fact that I'm working on Linux, which prevents me from go into the depths of the back-end.

Symfony project unable to load in localhost

I am new in symfony framework. Getting the below error when download the full project in localhost but it works in server.
Fatal error: Class 'Symfony\Bridge\Doctrine\ManagerRegistry' not found
in D:\wamp\www\DOFE\edin\vendor\doctrine\doctrine-bundle\Registry.php
on line 28
Thanks in advance.
You probably want to execute composer dump-autoload to force composer to regenerate the autoload namespaces for your app.
Regarding your comment, if you are getting this message it means you are in prod and you should switch to the dev environment to have details about the error (access to the symfony profiler).
Just add app_dev.php after the host in the url.

Symfony 2.4 You have requested a non-existent service "payment.encryption_service"

I'm migrating a symfony project from 2.0 to 2.4 version.
I've correctly configured all the parameters and services.
But the problem occured with JMS vendor, this is the error shown:
Fatal error: Uncaught exception
'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'
with message 'You have requested a non-existent service
"payment.encryption_service".' in
C:\wamp\www\symfony\app\bootstrap.php.cache on line 2027
This message is blocking me, do you have any issue, any idea?
I had the same problem. I don't know exactly what happened, but my problems went away after I manually cleared the cache using
rm -rf app/cache/prod/*
Considering your settings are on Windows, try manually deleting entries at app\cache\prod using Windows Explorer. I couldn't use app/console cache:clear --env=prod since the console would crash after showing that error message.
Another correct answer could be checking every service.yml in yml parser, for example http://yaml-online-parser.appspot.com
You have requested a non-existent service
could mean, that symfony can't parse correctly .yml files.
This means your the mentioned parameter is missing from your app/config/parameters.yml or other alike file that you are using to store your parameters. Set this parameter to a value and it should work.
E.G. I had the same error being "You have requested a non-existent parameter "domain".
I then added following line to the parameters.yml file:
domain: example.com
That did the trick.

Setting up php-sdk-gae with symfony2

I'm trying to run symfony2 with a hello world sample bundle inside php-sdk-gae.
I'm following the instructions provided in https://developers.google.com/appengine/docs/php/ and I can run the demo with the development controller (i.e: configuring app.yaml as following:
application: helloworld
version: 1
runtime: php
api_version: 1
handlers:
- url: /bundles
static_dir: helloWorld/web/bundles
- url: /favicon.ico
static_files: helloWorld/web/favicon.ico
upload: helloWorld/web/favicon.ico
- url: /.*
script: helloWorld/web/app_dev.php
It works fine, and I am able to get a Hello World after running the server and load /hello/World page
But when I try to run it with the production controller (app.php instead app_dev.php), I get an internal server error.
Request URL:http://mysite.local:8080/hello/World
Request Method:GET
Status Code:500 Internal Server Error
The only clue is in the console window where I launched the server, showing the lines ...
ERROR:root:php failure (255) with:
Status: 500 Internal Server Error
X-Powered-By: PHP/5.4.15
Content-type: text/html
If I make some changes in app.php files, I realize that it works fine with following AppKernel loading lines:
$kernel = new AppKernel('prod', true);
$kernel = new AppKernel('dev', false);
$kernel = new AppKernel('dev', true);
But not with the default configuration for the production enviroment ('prod',false).
I'm launching GAE server with this command:
google_appengine/dev_appserver.py --php_executable_path=/home/jon/php-sdk-gae/php-5.4.15/installdir/bin/php-cgi helloWorld/
I'm new in GAE, and I wonder Where can I find logs to get some more information about this error.
There is an uncaught exception in your production environment. Thats the reason for the http 500 error.
Let me quickly explain AppKernel::__construct
$kernel = new AppKernel($environment, $debug);
The first argument is the environment , the second one is the debug option.
If you set debug to true , symfony will try to catch exceptions and show you a nice stracktrace.
This covers the first and the third case where you don't get the http 500 error ( caused by an uncaught exception ).
$kernel = new AppKernel('prod', true);
$kernel = new AppKernel('dev', true);
Now you state the error is NOT thrown in dev environment with debug set to false.
$kernel = new AppKernel('dev', false);
This means in dev environment there is no exception.
Now you have to check the production log file to find out which exception has been thrown.
Use tail -f to see the live changes made to that file in your shell ( i.e. bash ) or if not available open the file in your editor and look for exceptions at the end.
tail -f app/logs/prod.log
In the symfony2 standard edition logfiles can be found at
app/logs/%kernel.environment%.log
... with %kernel.environment% being one of dev/prod/test
The problem is related with .htaccess file shipped with Symfony 2.2
I can use without any problem an application in symfony 2.0, and my application with Symfony 2.2 also works if I replace the web/.htaccess file shipped with Symfony 2.2 with the one shipped with Symfony 2.0
Maybe it is something related with the change made in order to avoid duplicate content (/app.php/something and /something), because since Symfony 2.2, /app.php redirects (301) the request.
I believe the problem is the lack of write support on the filesystem imposed by GAE. Also, symfony seems to rely on tempnam() function that's disabled in versions lower than 1.9.18 which is not public available at the moment I'm writing this.
There is also a problem with caching.
Maybe the problem is this, I've tried in localhost a project with developement version, all right. And when it's deployed to GAE it fails.
Maybe that helps.
http://www.ideato.it/planet-ideato/symfony2-su-google-app-engine/

Categories