My problem is the next one,
I tried to integrate the google login using OAuth 2.0 feature into my company backend.
I tested it on my domain , www.gabrielestevez.com, everything here works perfect, there is no problem with the require paths, everything runs smothly
But , the company backend directories has the following structure
I'm using a mvc framework developed by me , the Google_SL.php file contains the class where I make the first two require_once
require_once 'Google/Client.php';
require_once 'Google/Service/Oauth2.php';
which works fine, but then when it goes to the client.php and is trying to load this class
require_once 'Google/Auth/AssertionCredentials.php';
is not working , this is the error
An error occurred in script '/home/xxx/public_html/admin/hmf/Core/library/auth/Google/Client.php' on line 18: require_once(Google/Auth/AssertionCredentials.php) [function.require-once]: failed to open stream: No such file or directory
Date/Time: 9-19-2014 11:50:29
, I don't want to change manually all the path within this library because I know there is got to be a better solution to this
any input is appreciated.
for future reference
I fixed my issue using this
set_include_path($_SERVER['DOCUMENT_ROOT'] . '/admin/hmf/Core/library/auth/' . PATH_SEPARATOR . get_include_path());
Try use __DIR__ to get the current directory of the script. Not exactly sure where your AssertionCredentials.php is, but try something like
require_once(__DIR__ . '/Google/Auth/AssertionCredentials.php');
Related
I am getting a weird issue with a yii2 application (based in yii2-app-advanced) in the server, the thing is that the app frontend and backend are running ok, but the console tool (the yii script) is not working and is not throwing any errors.
Doing some debug by printing I have been able to track the issue to the requires calls in this block of code inside the script:
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/common/config/main.php',
require __DIR__ . '/common/config/main-local.php',
require __DIR__ . '/console/config/main.php',
require __DIR__ . '/console/config/main-local.php'
);
But I have no idea why the requires calls are failing without throw any errors. The config paths are ok and the files has no syntax errors (my local copy with same php and mysql versions works ok)
I have other yii2 apps in the server and they are working just ok.
Any tip will be really helpful because this thing is driving me crazy...
Seems that was a corrupted file in the project or composer, I Have cloned the project again, cleaned the composer cache, and installed the vendors, and now is working ok.
Resolving the issue. My Case:
Before reading the question, my issue was solved due to my development environment. Using CodeKit (an application on MacOS), upon building my code from the source folder, items such as the composer.json and other files did not transfer causing the issues described below. If this does happen to you scout the two folder to look for discrepancies the paste the missing docs from the src to the build folder.
:: QUESTION ::
I am starting to use GCP today and after following the instructions defined here:
composer require google/cloud-storage
then:
putenv("GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.json");
require __DIR__.'/vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$myid = "my-project-id";
$storage = new StorageClient([
'projectId'=>$myid
]);
var_dump($storage->buckets());
When running this i get the following error:
Fatal error: Class 'Google\Auth\Cache\MemoryCacheItemPool' not found in /place/to/vendor/google/cloud-core/RequestWrapperTrait.php on line 94
I have no idea how to solve the issue, as i am just getting started with GCP. No idea whether this is a problem with the platform or my code.
File structure appears as follows for the Google Auth:
vendor
google
auth
src
tests
cloud-core
cloud-storage
the /Cache/MemoryCacheItemPool exists inside both the tests and src folder, but the above is referencing it minus the src or tests folder.
I have also ran:
composer update
and uninstalled and reinstalled the package to no effect
Google Cloud Project Link
Where did you find the code that you used and pasted? Because the one present in the official documentation is different.
This portion of code is the one in the tutorial you linked, try to use the client library and post the error logs if get any!
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$projectId = 'YOUR_PROJECT_ID';
$storage = new StorageClient(['projectId' => $projectId]);
$bucketName = 'my-new-bucket';
$bucket = $storage->createBucket($bucketName);
echo 'Bucket ' . $bucket->name() . ' created.';
Remember that bucket name should be unique and therefore I would advice you to test it with a long complex name to avoid to hit already used names, and always test the result of the operation.
UPDATE
I tested also your code and it is working as well, therefore I believe that is an error in the setup of the environment.
Did you get any error while running the composer require google/cloud-storage? Because the class that is missing Google\Auth\Cache\MemoryCacheItemPool is part of Psr that is installed by the composer
[...]
Installing psr/cache (1.0.1)
Loading from cache
[...]
UPDATE2
Matthew M found the error in its configuration and posted:
Finally resolved the issue. I'm using CodeKit in my working
environment and it looks like it is changing something when it
compiles. Ran an uncompiled version and it's working fine.
i created a script in order to insert some articles via a php script. This script is working on my local machine (xampp), but when i deploy the whole joomla project to my web server i get the following error message:
Error displaying the error page: Application Instantiation Error: Application Instantiation Error
By adding some echo calls, i was able to find the line which causes the error:
$app = JFactory::getApplication('site');
Now i am wondering how to fix this behaviour and make my function also run on the web server.
Below i will provide my system informations and the beginning of my php function until the line, which causes the error message:
Systeminformations
joomla version: 3.6.5 Stable
db version: 5.6.34-79.1-log
php version: 5.6.30-he.0
web server: Apache
PHP snippet
<?php
echo "STARTING; ";
// get db connection
include('../includes/mysql.inc.php');
// get all sql querys
include('./autoNewsQuerys.inc.php');
/**
* Prepare joomla framework to insert article correctly
*/
if (!defined('_JEXEC')) {
define('_JEXEC', 1);
define('JPATH_BASE','/is/htdocs/wp1088688_4E1H7PYJFK/www');
require_once(JPATH_BASE . '/includes/defines.php');
require_once(JPATH_BASE . '/includes/framework.php');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
}
echo "searching app;";
$app = JFactory::getApplication('site');
echo "Found app;";
Full browser output
STARTING; searching app;Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/is/htdocs/wp1088688_4E1H7PYJFK/www/1500AutoNews/autoNews.php" at line 3.
So as you can see the error is caused by the JFactory call. 'Found app' is never printed out.
Just copy the Joomla index.php file to another file and then replace the $app->execute code with your code.
Note: You don't need to include any MySQL library - since you are loading the Joomla environment then you have access to the JDatabase class, which is a database abstraction layer.
Another note: this file autoNewsQuerys.inc.php likely contains some issues (maybe you are trying to instantiate the app there, but the Joomla environment hasn't loaded yet). You should move it to the end.
if it was working on localhost and it is not working on Web server then the biggest issue is with defining the base path. Give a hardcoded base path of your joomla installation. I suggest you to check your base path using a php script. Create a php file and name it path.php. Put it in the Joomla main folder. Content of the file
<?php
echo "The Base path is ".getcwd();
?>
Once you get the path just change the Base_Path. For ex:
define('JPATH_BASE', '\var\www\joomla');
I'm trying to setup a php client for RPC with a HBase Thrift server but I'm getting some errors at the begining ... I've compilated the HBase.thrift file (with the 0.9.1 compiler) and I've put the 2 generated files like bellow (/ is the root of my project, I'm using apache server on ArchOS) :
/include/Hbase.php
/include/Types.php
I've included the lib folder of thrift0.9.1/lib/php/lib (composed of Thrift and sub folders) under / and so I've the following file system :
/include/HBase.php
/Types.php
/Thrift/Base
/ClassLoader
/Exception
/ext
...
To be able to use my service (HBase.php) I've to load files so my code is the following :
<?php
$GLOBALS['THRIFT_ROOT'] = PHYSICAL_PATH;
// Load up all the thrift stuff
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Protocol/TProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TBufferedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Type/TMessageType.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Factory/TStringFuncFactory.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/StringFunc/TStringFunc.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/StringFunc/Core.php';
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Type/TType.php';
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\TSocketPool;
use Thrift\Transport\TFramedTransport;
use Thrift\Transport\TBufferedTransport;
//hbase thrift
require_once ('Hbase.php');
require_once ('Types.php');
?>
When I'm charging the different files, I'm getting an error for this line --require_once ('Types.php');-- and the error is : Fatal error: Class 'Thrift\Exception\TException' not found in /var/www/html/POCThrift2/include/Types.php on line 1266
I understand it like : When I tried to include Types.php, the Thrift\Exception\TException namespace was not use (despite the use Thrift\Exception\TException; in the beginig of the Types file) but I don't know why I'm getting his error ... can you help me ? Does anyone has encountered this problem before ? Thx in advance, I'm stuuuck right now ...
I've spent a lot of time troubleshooting this myself but none of what I've read solves my issue so I'm hoping I get some help here.
So anyway, I have written a PHP script that provides various functions to connect with Google Calendar. When I run this script directly using some inline test code to call my functions, everything runs fine. However, when I call the function from other scripts using 'require_once' to include it I get the following errors:
Warning: include_once(Zend\Gdata\Calendar\Extension\EventQuery.php) [function.include-once]: failed to open stream: No such file or directory in C:\Users\Luke Franklin\Clients\Tiers For Tea\Development\TiersForTea.com v1.1\lib\Zend\Loader.php on line 134
Warning: include_once() [function.include]: Failed opening 'Zend\Gdata\Calendar\Extension\EventQuery.php' for inclusion (include_path='.;C:\xampp\php\PEAR;C:\Users\Luke Franklin\Clients\Tiers For Tea\Development\TiersForTea.com v1.1\lib;C:\xampp\htdocs\TiersForTea.com\lib') in C:\Users\Luke Franklin\Clients\Tiers For Tea\Development\TiersForTea.com v1.1\lib\Zend\Loader.php on line 134
Your first thoughts might be that I'm not using the correct include path, but I have checked and rechecked this many times. I even tried hard coding the path. I'm quite sure that I'm using the correct path.
Now for the weird bit. If you look at the error you will notice the file Zend is trying to include: Zend\Gdata\Calendar\Extension\EventQuery.php. This file does not actually exist in the 'Extension' folder. It does exist in the parent folder though. If I just copy 'EventQuery.php' into the 'Extension' folder my script runs as expected. Weird, right?
So that does sorta solve my problem, but I would like to know what's going on here in-case it creates further issues. I should also note that I'm calling this script into an OpenCart module.
You might want to see some of my code so here's a snippet of the important bits, if you want more details just let me know:
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('\\lib') . PATH_SEPARATOR . "C:\\xampp\\htdocs\\TiersForTea.com\\lib");
require_once('Zend/Loader.php');
function connect() {
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
I doubt the error exists in any of the Zend files as you have indicated it works correctly in your isolation tests.
The error is thrown from Zend_Loader which means something in your code is making reference to Zend_Gdata_Calendar_Extension_EventQuery.
Check the stack trace for the error if available to pinpoint the location. If that's not available, do a global find for that string. If you find any matches, you will need to change them to Zend_Gdata_Calendar_EventQuery.
Update
Seems this is a known bug(s)
http://framework.zend.com/issues/browse/ZF-7013
http://framework.zend.com/issues/browse/ZF-11959
It's an issue when your code registers an error handler using ErrorException. Apparently it's fixed in the 1.12 branch but hasn't made it to a release yet.
There's a patch in the 11959 bug report that fixes the issue