Doctrine undefined function apc_fetch - codeigniter

I'm using this tutorial, which gives a detail explanation about how to set up CodeIgniter and Doctrine. I'm using CodeIgniter 2.1.0 and Doctrine 2.2.1, but I get this error:
Fatal error: Call to undefined function Doctrine\Common\Cache\apc_fetch() in /Applications/XAMPP/xamppfiles/htdocs/emma_watson_shrine/application/libraries/Doctrine/Common/Cache/ApcCache.php on line 52
Can you help me out?

You need to enable the APC extension for PHP.
Follow this guide.
Alternatively, you could use a different caching driver, like memcache, and change the Doctrine config in accordance to that.
Check the doctrine documentation for alternate caching drivers. Perhaps the simplest solution would be to use ArrayCache in development.

Since php 5.5 apc is no longer used. You should install apcu.
E.g.
apt install php5.6-apcu
More info here:
http://php.net/manual/en/opcache.installation.php
And for those on php 7 there's a backwards compatibility module:
apt-get install php7.0-apcu
apt-get install php7.0-apcu-bc
Also, you might need to add this repository:
apt-add-repository ppa:ondrej/php
apt-get update

If you don't install APC and just want to run it then in doctrine-cli.php at line 6, change mode:
define('ENVIRONMENT', 'production');
to
define('ENVIRONMENT', 'development');
Open Doctrine.php file, at line 36 ~ 43, you will see why!

you need to install apc extension to work with caching. So just download the extension and install it.
This one will help you to install APC extension on apache.
http://kvcodes.com/2014/06/solution-call-undefined-function-apc_fetch/

For anyone getting this on a Mac, just install apcu using Homebrew:
brew install php56-apcu
(and enable the extension, if required).

On OSX I had to run:
pecl channel-update pecl.php.net
pecl install apcu-4.0.11
to install for PHP 5.6
https://getgrav.org/blog/macos-mojave-apache-mysql-vhost-apc

Related

Laravel: [ErrorException] "continue" targeting switch is equivalent to "break". during "composer install"

When I run ...
composer install
... on a server with PHP and nginx installed.
I get the following exception:
[ErrorException]
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
How can I fix this?
This is a new warning introduced in PHP 7.3.
It means you are not allowed to have a continue statement inside of a switch, you should use break instead.
To fix this you most likely just have to update composer, this can be done simply by running composer self-update.
You can also just run php without warnings, this can be done by setting the ini config values as a start parameter.
php -d error_reporting=0 composer.phar
Check your current PHP version if it's greater than 7.2, then execute follow below simple steps
1. Disable the latest php version
sudo a2dismod php7.3
2. Restart the nginx service
sudo service nginx restart
3. If you are using Apache2 run as below
sudo service apache2 restart
4. Set alternatives
sudo update-alternatives --set php /usr/bin/php7.2
5. Check the PHP version
php -v
6. Now, Install Composer as below
composer install
Old composer uses continue statement in their code within the switch which is outdated and cannot be used anymore with latest version of php.
you need to update your composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=bin
for more details visit composer download
It was because of an outdated composer. After searching a lot finally the following works for me:
Uninstall the old composer.
Install a new updated composer.
You can download or install composer from this link: https://getcomposer.org/download/
For me,
just go to this file
sudo nano /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php
As a quick and dirty alternative, you can fix the error in that file. Just replace "continue" with "break"

Installing APC on Centos PHP7

I am trying to get the modules installed for an old Symfony site.
I tried
sudo yum install php-pecl-apc
returned
No package php-pecl-apc available.
I can't apt-get s it is not installed. How can I get this module installed
php-pecl-apc is not available for centos7, so you need to install php73-php-pecl-apcu.
Note- not available in official centos repo, so you have to use Remi repo.
https://centos.pkgs.org/7/remi-x86_64/php73-php-pecl-apcu-5.1.17-1.el7.remi.x86_64.rpm.html
Thanks
APC is a dead project, no stable version was released for any version of PHP > 5.3.
For opcode cache, the opcache extension exists for PHP 5.x and is now part of PHP 7.x
For user data cache, the APCu extension version 4 exists for PHP 5.x and provides a new API, and a compatibility layer to emulate APC
For PHP 7.x, APCU version 5 only provides the new API, but the apcu_bc extension provides the compatibility layer.
How do you install PHP 7 on your CentOS box ? Good package providers have these extensions available (php-pecl-apcu and php-pecl-apcu-bc).
P.S. "remi" repository is a possible provider for PHP and its extensions, follow the wizard instuctions.

Installing Silverstripe with puppet

I'm trying to use puppet to create a default installation of Silverstripe for testing new projects. Is there a way to install silverstripe using just the commandline?
You can create a _ss_environment.php file, then run php framework/cli-script.php dev/build. The default mysite/_config.php is set up for this already.
You can read more on the _ss_environment.php file in the docs.
If your hosting environment either has composer or allows you to install software, using composer to install from the command line is an option. Refer: Installing and Upgrading with Composer

Cant' get MongoDB PHP Extension to work

I've been following this tutorial to try to install the PHP MongoDB extension but unfortunately haven't been able to get it working.
http://www.marcwitteveen.com/tech/mac/installing-mongodb-on-a-mac-so-you-can-access-it-with-php/
I can access the collections in the terminal, the database is properly installed but I didn't manage to get the extension working.
I have the following problem:
Sinan-MBP:mongo-php-driver-master Sinan$ cd
Sinan-MBP:~ Sinan$ sudo pecl install mongo
pecl/mongo is already installed and is the same as the released version 1.4.1
install failed
I've been trying several times so that's probably why I get this message. However, even after adding "extension=mongo.so" to the php.ini, I can't use MongoDB in my PHP code.
Thank you for your help.
This is likely a case of modifying the wrong php.ini for the environment, or PHP not being able to find the mongo.so in its directory. If you have separate php.ini files for CLI and web environments, PECL might have installed the compiled extension to a different directory.
If you run through the installation docs, there are instructions for grepping extension_dir from php -i and ensuring that mongo.so is present in that directory. If your web environment has a separate php.ini file, then grepping output from php -i likely won't help. You may need to view phpinfo(); output through your web server and check for the extension directory there.
One additional test that PECL installation succeeded would be attempting to view reflection information for one of the driver classes from the CLI environment. You can do so with php --rc MongoClient, which should print info on the methods of the MongoClient class.
I don't know why it was not working but I found a workaround late last night.
I uninstalled the php extension and then installed it again and made sure the extension was loaded in the php.ini
sudo pecl uninstall mongo
sudo pecl install mongo

Missing mbstring PHP extension when installing phpMyAdmin on Mac

PhpMyAdmin install errors
Having some issues with installing phpMyAdmin. I would like to resolve the following issue, but don't have a clue where to start (except maybe php.ini?).
Here's the error message.
The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
And here's a related article I found on SO that was for Linux but didn't work on my Mac (OSX 10.6 with PHP updated, etc): PhpMyAdmin install errors
Like the error message says, your PHP installation lacks the mbstring extension. The Apple-provided PHP 5.3.3 in my Snow Leopard seems to have it, but many distributions bundle the extensions separately. For instance, if you use PHP from macports you need to install the php5-mbstring -package with:
sudo port install php5-mbstring
Minor note - if you have installed a different version of php (like php5.5) you must install the correct version of the mbstring package. In my case:
sudo port install php55-mbstring
To activate, you have to have a line like this in your php.ini file:
extension=mbstring.so
Which comes from:
/opt/local/var/db/php55/mbstring.ini
(if you use the default macports install root).
In the newest php versions the "extension_dir" path is not enabled initial.
It works with Windows and Linux, so maybe it helps also on MacOs ... :)
screenshot

Resources