I have Phalcon php micro application setup on my dev machine and it is working fine. However, I've pushed it to the production machine and it is saying it can't find any of the model classes. I get the error
Fatal error: Class 'ItemType' not found in /var/www/html/api/index.php on line 115
The strange thing is nothing has changed except for the password to the database which I've updated so the app can log in.
I've setup all my registered directories also
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
__DIR__ . '/models/',
__DIR__ . '/decorators'
))->register();
What would be the reason for this?
Okay, so just found out that my dev machine is handling the file name differently. It is case sensitive on the amazon machine.
My itemtype.php file needed to be ItemType.php. This goes with all model files.
Face palm.
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'm using Doctrine ORM in my PHP project.
In one of my queries I'm using the 'COS' (cosine) and 'SIN' (sine) functions, in order to make this possible on Doctrine I have to add this to my entitymanager configuration:
$config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\cos');
$config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\sin');
This works fine when I run it on my local PC + server.
But once I put the project on the online webserver I'm facing with these errors:
Fatal error: Class 'DoctrineExtensions\Query\Mysql\cos' not found in /home/USER/domains/USER.com/public_html/MYDIRECTORY/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php on line 3418
Fatal error: Class 'DoctrineExtensions\Query\Mysql\sin' not found in /home/USER/domains/USER.com/public_html/MYDIRECTORY/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php on line 3418
It's looking in the 'vendor\doctrine' directory instead of the 'vendor\beberlei\DoctrineExtensions' directory.
My composer contains:
"beberlei/DoctrineExtensions": "dev-master"
And the vendor autoloader contains:
'DoctrineExtensions\\' => array($vendorDir . '/beberlei/DoctrineExtensions/src')
Can anyone explain this to me... I tried adding a classloader, but still the same problem.
Localhost is working fine...
When adding sine and cosine functions to the entitymanager config I used:
$config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\cos');
$config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\sin');
The solution above is working on a local PC + server.
When moving the project files to the webserver the above config won't work.
You have to change the first letter of the last word in the DoctrineExtensions namespace to uppercase, like this:
$config->addCustomNumericFunction('COS', 'DoctrineExtensions\Query\Mysql\Cos');
$config->addCustomNumericFunction('SIN', 'DoctrineExtensions\Query\Mysql\Sin');
Basically cos becomes Cos and sin becomes Sin .
Now it works on the online webserver. Finally got it working!
I installed composer in my CodeIgniter project, downloaded 2 packages: Aura/Sql and Aura/SqlQuery
this is my code from index.php file
require_once ROOTPATH . 'vendor/autoload.php';
use Aura\Sql\ExtendedPdo;
$db = new ExtendedPdo('mysql:host=127.0.0.1;dbname=mydb', 'root', '', array(), array());
var_dump($db->fetchAll('SELECT * FROM sh_users'));
use Aura\Sql_Query\QueryFactory;
$query_factory = new QueryFactory('mysql');
require_once BASEPATH . 'core/CodeIgniter.php';
both fragments are copied from documentation
var_dump gives perfect result, but QueryFactory gives me error
Fatal error: Class 'Aura\Sql_Query\QueryFactory' not found in F:\XAMPP\htdocs\codeigniter\public\admin\index.php on line 83
and i have no idea why. all vendors are downloaded and all php files are there, but it seems autoload doesnt load it. why?
Take a look at the file structure on disk; you may actually want to be including Aura\SqlQuery\QueryFactory, instead of something under the Sql_Query namespace. It may be something as simple as that. I've encountered issues when I've forgotten to rename the class in a PSR-0 compliant path such that it matches the file name, so if in fact the contents on the disk are in:
Aura\SqlQuery\QueryFactory but your use statement is Aura\Sql_Query\QueryFactory, you'll run into a problem.
As mentioned below in the comments, it appears that the Aura devs have two branches, the master branch on the Githup project auraphp/Aura.Sql_Query still has the directory structure as Sql_Query where as the default package, served by packagist, serves the dev-rename branch which replaces Sql_Query with SqlQuery.
Hope that helps!
I am getting Class 'Splash\\SiteBundle\\Util\\Resize' not found when running my app on prod. This does not happen on dev.
Here is the code from the error:
$resize = new \Splash\SiteBundle\Util\Resize($this->getAbsolutePath());
I have a file called Splash\SiteBundle\Util\Resize.php with this namespace
namespace Splash\SiteBundle\Util;
Class Resize{ ... }
Any thoughts?
So the quick fix is to add this include dirname(__FILE__) . "/../Util/Resize.php"
I am not sure why my production machine would need the include while my dev machine works fine without it. Using Symfony2 and the autoloader I have never needed to include a file. Not sure whats goin on but this get me past it for now
One of the possible thing that could lead this to happen could ne not cleared cache
php app/console cache:clear -e prod
Another stupid thought could be that production has merge conflicts within that file and PHP doesn't see the class compiled.
I love when its the little things. My util folder was not capitalized. I changed this and it works now. I'm surprised my dev machine did not fail w this error.