Phalcon module loaded but still class can't be found - php

I have installed Phalcon on my vServer and it seems to be loaded,
but if I try to run website I get an error
PHP Fatal error: Class 'Phalcon\\Config\\Adapter\\Ini' not found in /home...
php -v
PHP 5.6.10 (cli) (built: Jun 11 2015 08:33:51)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
I followed the instructions on Phalcon website.
If I list php modules using php -m Phalcon is listed, I don't have
any errors, just don't know why it's not working!
Also, Phalcon is not listed on phpinfo(); page.

looks like you changed the config for the php console client but that config is not the same for the php module in apache.
Review what config is being loaded for apache module

When installing phalcon in order to get the extension working make sure to restart nginx / apache2, and if you are running PHP as a module php5-fpm service as well.
$ sudo service nginx restart
$ sudo service php5-fpm restart

I encountered the same problem and the reason is that I recompiled php with source code but not recompiled phalcon again after that. I solved that by compiling phalcon again with the correct phpize.

Sometimes when phalcon is installed, it creates a separate .ini file for itself and adds the extension therein. This is common in mac and linux OS. In such situation, type php --ini on the terminal. You should see an out put similar to the following...
Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File: /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini,
/usr/local/etc/php/5.6/conf.d/ext-phalcon.ini
As you can see, phalcon created the /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini file.
SOLUTION:
Open the file using sudo nano /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini, copy the line in which the extension is loaded and paste in /usr/local/etc/php/5.6/php.ini if you are using XAMPP, copy the line to /Applications/XAMPP/xamppfiles/etc/php.ini Restart your server and check if that works.

Related

PHP not running on MacOS Monterey 12.4

I recently switched from Linux/Ubuntu to Mac. I Installed Apache2 and PHP 8 using homebrew on my MacOS Monterey 12.4 which came preinstalled with my MacBook Pro (M1). I have successfully configured the Apache and it is working perfectly as I am able to access my localhost. I have even changed the document root from its default location to my customized location (in my home directory)
After Successfully installing apache I installed php. I verified this by running the following commands
isthakur#Inders-MacBook-Pro apache2 % php -v
PHP 8.1.6 (cli) (built: May 12 2022 23:30:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
PHP is installed on following location /opt/homebrew/bin/php
but I am unable to get output on browser I have created a php file on my document root with following codes and named it test.php
<?php
phpinfo();
?>
When I try to open this file through browser (http://localhost/test.php) the codes are displayed on browser which means that server is not processing PHP.
Any kind of help is welcome and I thank everyone in anticipation.
Regards
after reading blogs and responses online I found that MacOS comes preinstalled with apache and even php was pre installed prior to MacOS Monterey (12) So I reset my Mac and found that apache is preinstalled and I just need to run it using following command
sudo apachectl start
and I can access apache. Since PHP was not installed I need to install it using homebrew. after installing the php I saw that I need to modify my https.conf file as following.
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/opt/homebrew/etc/php/8.1/
To restart php after an upgrade:
brew services restart php
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

Is ioncube loader working in my case?

I used Putty to install ioncube loader. Used php -v to check and it shows
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.
However, I inserted a page with the following code in my website to check:
<?php
phpinfo();
?>
but it doesn't show that ioncube loader is enabled.
I also used:
<?php
echo var_export(extension_loaded('ionCube Loader') ,true);
and it returned false.
My Server API is CGI/FastCGI so I have already included
zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.4.so
in the following file /etc/php5/cgi/php.ini
I wonder if it's really working or not?
A common mistake over time is having a different major PHP version for CLI and the web server, so perhaps your website does not use PHP 5.4. Another gotcha is using a different php.ini for website and cli, or having a php.ini in the same location as a web request that, on a cgi system, overrides that main php.ini. The web server software or fastcgi pool in this case may also need to be restarted.
First of all, go to your terminal and type which php this will show you the directory of the particular php.ini file that is currently being used by the php installed on your computer.
Open the php.ini file and make you have added this line zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.4.so before any other Zend extension is loaded on the php.ini file.
Also note that the ionCube loader ioncube_loader_lin_5.4.so will only for PHP 5.4.* only.
Make sure you have copied the file into the directory you stated, you can verify by tying cd ~ and then sudo find /usr/local/ioncube/ioncube_loader_lin_5.4.so to make sure the file is situated there, if it is the terminal will return the file name showing it found it.
Now save the changes made on your php.ini file and run the command sudo apachectl restart (for Apache servers) to restart your server.
Test with php -v from your terminal again.
Hope this helps.

Apache stuck with working after Xdebug was installed. Ioncube loader error

I have a local installation of Ubuntu Server 12.10 via VirtualBox for my PHP programming purposes.
Recently I've installed the Xdebug in this way:
sudo apt-get install php5-xdebug
Then added 'xdebug' path to my /etc/php5/apache2/php.ini:
zend_extension=/usr/lib/php5/20100525+lfs/xdebug.so
Then I restarted apache.
And, it got stuck. My local sites are not loading. The 'php -v' (as well as 'php -m') says:
PHP Fatal error: [ionCube Loader] The Loader must appear as the first
entry in the php.ini file in Unknown on line 0
Thing is that I don't have Ioncube installed. I tried to google this error-mesage, but everywhere said that it seems a wrong installed Ioncube, or something with xdebug and ioncube incompatibility. But I dont have inocube installed at all!
What is wrong? How can I make my apache live again? Projects are burning :(
UPDATE:
I've found a reason. It seems that 'php5-xdebug' package has a built-in fix for the ioncube-xdebug incompatibility. When I installed it, I got the file /etc/php5/conf.d/ioncube.ini where ioncube included as zend extension. I got this file with the php5-xdebug package.
So I removed that file and apache became live.
Ioncube must be loaded before any other extension, so to fix this problem do this:
goto /etc/php5/conf.d
type mv ioncube.ini 01-ioncube.ini
restart apache service apache2 restart
Enjoy with ioncube and xdebug :)
Comment ioncube loader in the includes foldes of apache installation and move it to extensions block in php.ini so it would look like this:
zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
Basically you must load ioncube first and only then xdebug.

How do I set up PHP-debugging on Ubuntu 12.04 with Eclipse and XAMPP?

I've been trying to configure this for quite some time now but I can't get it running properly. Done so far:
Downloaded the latest version of xampp and moved it to /opt/lampp
Installed php5-xdebug with apt-get
Changed implicit_flush to On in /opt/lampp/etc/php.ini
Added the following lines to the end of the ini file:
[xdebug]
zend_extension="/usr/lib/php5/20090626/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
xdebug.remote_host="localhost"
I've made sure to restart apache, but I still don't get an xdebug-section when showing phpinfo();
I think that Eclipse is configured properly, but I can't know for sure until I get xdebug to run.
Please help, all suggestions are very welcome!
Edit:
Here is the output of phpinfo(): http://www.pasteall.org/35930
Update:
I've downloaded Xampp 1.8.1 (I had previously xampp 1.8.0) to /opt/lampp and added the appropriate development files. I have both compiled Xdebug myself according to the guide at http://xdebug.org/wizard.php and installed xdebug through /opt/lampp/bin/pecl.
Now my php.ini looks like this:
zend_extension = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
I don't know what to do, http://xdebug.org/wizard.php still reports that Xdebug isn't installed. Could it be a permission issue? Currently the permissions for the extensions are as follows:
-rwxr-xr-x 1 niklas niklas 88376 Sep 30 10:43 interbase.so
-rwxr-xr-x 1 niklas niklas 184920 Sep 30 10:43 oci8.so
-rwxr-xr-x 1 niklas niklas 118592 Sep 30 10:43 pgsql.so
-rwxr-xr-x 1 niklas niklas 830886 Oct 10 15:10 xdebug.so
Should they be owned by someone else? Must I enable any additional options in php.ini? This is my current output of phpinfo(): http://www.pasteall.org/36135
Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 5.4.4
Zend API nr: 220100525
PHP API nr: 20100525
Debug Build: no
Thread Safe Build: no
Configuration File Path: /opt/lampp/etc
Configuration File: /opt/lampp/etc/php.ini
Extensions directory: /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525
Instructions
Download xdebug-2.2.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.2.1.tgzRun: cd xdebug-2.2.1
Run: phpize
As part of its output it should show:Configuring for:
...
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
If it does not, you are using the wrong phpize. Please follow
this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525
Edit /opt/lampp/etc/php.ini and add the linezend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
Restart the webserver
http://xdebug.org/wizard.php
See below URL i think it is very help full to you
http://www.edmondscommerce.co.uk/ubuntu/ubuntu-xampp-xdebug-install/
http://www.webhelp2u.com/article/install-xdebug-on-lampp
https://stackoverflow.com/questions/9640912/problems-setting-up-eclipse-with-xdebug
Read it:-
Install XDebug on ( LAMPP OR XAMPP For Linux )
http://www.edmondscommerce.co.uk/ubuntu/ubuntu-xampp-xdebug-install/
http://www.webhelp2u.com/article/install-xdebug-on-lampp
To Install XDebug on LAMPP
Download the latest version of ( XAMPP For Linux ) From site http://www.apachefriends.org/en/xampp-linux.html
Install it. To install lampp, extract and put in /opt directory.
Download Development package from same site.
Extract it, copy and paste "include" folder from Development package to /opt/lampp directory. ( This package would use for compiling XDebug source )
Run command /opt/lampp/bin/pecl update-channels. this would update the pecl channels database at your local pc.
Run command /opt/lampp/bin/pecl install Xdebug. And wait for finishing the process.
Now xdebug.so file has been created in /opt/lampp/lib/php/extensions/ directory.
Now Open the file php.ini and add the line zend_extension="/opt/lampp/lib/php/extensions/path_to_xdebug.so". at the end of file.
Restart Lampp & Check enabled or not using phpinfo();
Update my answer after your comment
See below URL i think it is very help full to you.
Setup Xdebug for PHP5 in Ubuntu
http://gayanhewa.info/setup-xdebug-php5-ubuntu/
Since there is no sign of why it isn't working I've given up on xampp and just installed a regular lamp-server with xdebug through apt-get. I disabled mysql and apache2 from starting during boot so that they are not running if I don't want them. Here is a very simple tutorial on how to enable xdebug-debugging with Eclipse: http://www.web-brainz.co.uk/Xdebug
The other answers will surely be the most fitting for other users though they unfortunately didn't fix my issue. Thank you very much for help!
On a fresh ubuntu 12.04 run:
apt-get install php5-xdebug
Check for xdebug if it is installed:
php --version
it looks like this:
root#ubuntu-SandBox:/var/www# php --version
PHP 5.3.10-1ubuntu3.19 with Suhosin-Patch (cli) (built: Jul 2 2015 15:05:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
root#ubuntu-SandBox:/var/www#
Modify your php.ini to load Xdebug run:
vi /etc/php5/apache2/php.ini
and add at the bottom of the file:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
/* this is the ip address of your PHPstorm IDE machine. */
xdebug.remote_host="10.70.111.11"
Restart your server:
service apache2 restart
Now your server is ready for your client IDE machine to connect.
Here is how to configure PHPSTORM:
Follow this instruction of JetBrain https://confluence.jetbrains.com/display/PhpStorm/Validating+Your+Debugging+Configuration
or
On menu Run => Web Server Debug Validation and you will see something like this:
If you dont get the yellow and everything is blue you are good!
Install chrome extension xdebug helper from here:
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
Start a debug session in browser by enable this extension by click on it and the bug icon turns green.
Then in IDE Run => Listening for php debug connections.
Set a breakpoint in the source code
Load your php page (webapp) and it will be stopped at breakpoints.
Done.

'Memcache' not found in command line PHP script

I have Memcache installed and working for PHP apps run through Apache (v2.2) but when I try to run a .php file in the command-line i get this error:
Fatal error: Class 'Memcache' not found in /usr/local/Matters/app/matters-common/connection.php on line 94
Line 94 is:
$memcache = new Memcache;
Other info:
CentOS 5.2
PHP 5.2.5 (cli) (built: Feb 20 2008 21:13:12)
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Apache v2.2.8
Presumably you have separate php.ini files set up for apache and the command line (cli).
If so, you need to add the following to your cli php.ini file:
extension=memcache.so
On Ubuntu it's in /etc/php5/cli/php.ini
If it's working then memcache should appear in the list of modules if you run php -m on the command line.
Alternatively, you can create a file /etc/php5/cond.d/memcache.ini with the same contents.
It is possible that you have a separate php.ini file for CLI mode. This file might not include memcache extension.
I did have this kind of error and I also did php -i | grep memcache and it says memcache is enabled, but my solution that solved the problem was when I edited the php.ini, i simply modified the extension_dir="./" line to the full path of the extensions directory which now looked like this, extension_dir="/usr/local/lib" -- you need to check where the extension directory of the php reside and make sure memcache.so is there..
then i simply restarted httpd and alas the problem is gone.
you can check the detailed steps here:
http://joemarie-aliling.com/223/php-programming/php-memcache-not-found-problem/
For simplicity sake I used:
php -c /etc/php.ini ./cli-script.php
If you do not know which php.ini your command line is using, type php -i. You will get a long list of settings, where somewhere near the top of the list you will see which php.ini is being used:
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.3.6/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)

Categories