pecl not working on php CLI mode (involving mongoDB in Gearman) - mongodb

For test purposes I have gearman running on localhost. So I run the gearman worker.php file from php command line. When I test this in normal apache mode, mongoDB works just fine, but when it runs from the gearman worker file I get the error "fatal error: class 'Mongo' not found". Now the Mongo class comes from pecl and the mongo.so extension in php.ini. SO yeah, trying to figure out why a php file run from CLI is different. Does it use a separate php.ini file?

You can check which .ini files are being loaded by the CLI version by doing php --ini. If your PHP was provided by a distro, it's very possible for it to have two seperate .ini sets, one for web-based and one for CLI. You can get the equivalent info from phpinfo() when it's running online as well.
To force it to load a particular .ini, you can use php -c /path/to/file.ini.

Well a simple find / -name php.ini answered that question for me. So yes, there is a separate php.ini file. Where I needed to add the line extension=mongo.so.

It sounds like either you're loading different ini files or you've got multiple instances of php installed on your machine and apache is using a different one. Make the script v.php:
<?php phpinfo();
then try running it from CLI and then viewing it via localhost. EG:
php v.php
and
http://localhost/v.php

Related

Issue with extension typo3_console due to not detected APCu module

I've TYPO3 8 installation via Composer. I'm experiencing an issue with using extension typo3_console v5.3.0 from CLI. For the command:
./vendor/bin/typo3cms extension:activate realurl
I get following error:
[ TYPO3\CMS\Core\Cache\Exception ]
The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.
My OS is Ubuntu 16 with Apache. I do have APCu installed, v5.1.11 . It is added to my php.ini extension=apcu.so and I can see it's loaded when executing phpinfo(). Furthermore APCu is detected in TYPO3 Install Tool → Configuration Presets → Extbase Object Cache, thus I use if for back-end caching. Looks like so far everything is fine. Btw. apc.shm_size=16M
Any ideas why I get this this error?
ps. when I type php -m in CLI I can't see APCu on the list. Perhaps this exception is thrown due to not finding APCu in the output of that commend, dunno.
Found a solution. PHP has a separate configuration file for CLI. APCu wasn't enable there..
You can find location of php.ini for CLI with this command:
php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"
In my case path to file is: /etc/php/7.2/cli/php.ini
assuming you already have installed APCu module, you need to enable access to it itself and access from CLI, basically those two lines of code:
extension=apcu.so
apc.enable_cli=On
After restarting Apache I was able to successfully execute commands like:
./vendor/bin/typo3cms extension:activate realurl

Command 'celeryd' not known when using ckanext-archiver

I'm using CKAN as my open data portal and am installing the Archiver Extension by following the instructions at https://github.com/ckan/ckanext-archiver. I have installed celery as shown:
Successfully installed celery kombu kombu-sqlalchemy messytables flask anyjson amqplib xlrd python-magic chardet json-table-schema lxml Werkzeug
But I am unable to run it.
/usr/lib/ckan/default/src$ paster celeryd -c /etc/ckan/default
Command 'celeryd' not known (you may need to run setup.py egg_info)
Known commands:
create Create the file layout for a Python distribution
exe Run #! executable files
help Display help
make-config Install a package and create a fresh config file/directory
points Show information about entry points
post Run a request for the described application
request Run a request for the described application
serve Serve the described application
setup-app Setup an application, given a config file
My CKAN root directory: usr/lib/ckan/default/src
path to ckan config file: /etc/ckan/default
Hope someone can help solve my issue. Thanks.
Sorry for the late answer but you need to be in /usr/lib/ckan/default/src/ckan context in order to perform the command.

PHPUnit and Mongo with Phactory

I am new to Unit testing and trying to use Phactory with Mongo, but when I run the test I keep getting the following error.
PHP Fatal error: Class 'Mongo' not found in /vagrant/Test/user/LoginTest.php on line 19
I know Mongo is installed because when I pull up the site it works, but for some reason PHPUnit isn't recognizing it.
I feel I am missing a step. Do I need to install the Mongo extension locally, or do I need to include the location in a config file somewhere?
Are you sure Mongo is installed as a module in the command line version of PHP?
Do a quick run of php -i and have a look at the output (which is phpinfo() without fancy formatting) or php -m for a list of modules. If the Mongo extension does not show up, you have to install it.
Also note that the Mongo class has been deprecated. You'd probably update to using MongoClient.

Magento: cURL extension has to be loaded

I want to run a copy of one of our Magento installations on my local machine. I've copied the code, recreated the database on my local machine, configured apache, and now try to run it. I get the following message:
There has been an error processing your request
cURL extension has to be loaded to use this Zend_Http_Client adapter.
I've searched for solutions on the internet, but couldn't find a solution.
Curl was not installed, so I did this: apt-get install php5-curl
I opened /etc/php5/apache2/php.ini and looked for php_curl.dll, which was not mentioned in it. So I added the following line: extension=php_curl.dll. After restarting apache nothing changed. Shouldn't that DLL be in there? I've tried to search for the string inside /etc/php5 and /etc using grep, but no results.
Now I wonder what to do to get magento working. I don't care about Curl, this installation is meant to test, try out, and it doesn't need all options installed. Best would be if this worked, but it's not a necessity for now.
I've changed php_curl.dll to php_curl.so and that seems to solve the problem.

Execute php commands in WAMP environment

I'm new to working in a WAMP environment, in this case I'm using Easyphp, and I can't find how to execute php commands (like a simple php -v), like I would do for example when connecting to a server with SSH.
I have Easyphp installed, apache and mysql servers are on, and I created a virtual host using the module in the same folder where I'm trying to execute the php command (using the cmd tool in windows).
Is there any other way to do this? Is there a "console" just for that? Any help would be appreciated!
EDIT
OK maybe I should give a specific example of what I'm trying to do in case I didn't explain myself very well. I'm trying to follow this guide to getting started with Zend Framework, and in the very first step after downloading the files, it asks to "type" 2 commands:
php composer.phar self-update
php composer.phar install
Where do I exactly "type" those commands?
In windows you need to set up your path environment variable (if it hasn't already been done by the installer) so that it points to the correct location for the PHP executables. Refer to the documentation for EasyPHP to see if/how you need to do this.
Then, open a dos window, and cd into the directory for your project. Then you should be able to run the commands as shown.