Mongo showing on php info but MongoClient not working? - php

I'm using a Mac and I've installed the Mongo Driver for PHP (5.3.1, my version). It shows up on php info but when I use it in my PHP script it wont work.
Here is what my PHP info shows:
MongoDB Support enabled
Version 1.0.11
Directive Local Value Master Value
mongo.allow_empty_keys 0 0
mongo.allow_persistent 1 1
mongo.auto_reconnect 1 1
mongo.chunk_size 262144 262144
mongo.cmd $ $
mongo.default_host localhost localhost
mongo.default_port 27017 27017
mongo.long_as_object 0 0
mongo.native_long 0 0
mongo.utf8 1 1
Thanks :)

I'm assuming that the version of mongo listed in phpinfo is 1.2 -- MongoClient class wasn't out until v1.3
if so, you need to update mongodb to the newer version.
https://bugs.launchpad.net/ubuntu/+source/php-mongo/+bug/1096587

Related

Problem to install (compile) PHP 7.2.34 from ASDF in Arch Linux on Windows WSL 2.0

I´m trying to configure a develop environment in Arch Linux on Windows WSL 2.0.
The Arch configuration I followed from Akita On Rails in this guide-tutorial (pt-br) video:
O Melhor Setup Dev com Arch e WSL2 (The best dev setup with Arch and WSL2)
So far, so good. I went to official github ASDF (asdf-vm) plugin (all plugins) PHP page (asdf-php) and followed the instructions:
  ~ ················································································································ at  11:37:47
❯ asdf plugin-add php https://github.com/asdf-community/asdf-php.git
  ~ ····································································································· took  17s at  11:38:28
php
No versions installed
  ~ ················································································································ at  11:38:37
❯
Then I try to install PHP 7.2.34 and get the following error:
❯ asdf install php 7.2.34
Determining configuration options...
/home/rod/.asdf/plugins/php/bin/install: line 323: locate: command not found
/home/rod/.asdf/plugins/php/bin/install: line 324: locate: command not found
Downloading source code...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 133 100 133 0 0 8 0 0:00:16 0:00:16 --:--:-- 34
100 16.9M 0 16.9M 0 0 496k 0 --:--:-- 0:00:35 --:--:-- 3791k
Extracting source code...
Running buildconfig...
Forcing buildconf
Removing configure caches
buildconf: checking installation...
buildconf: autoconf version 2.71 (ok)
rebuilding aclocal.m4
rebuilding configure
...
If configure fails try --with-webp-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
configure: error: png.h not found.
  ~ ··································································································· took  1m 9s at  11:46:33
❯ asdf list php
No versions installed
  ~ ················································································································ at  11:48:23
❯
When finished the ASDF PHP list shows: "No versions installed", but I´m not know what I need to configure to make this work.
I even tryied to update the plugin:
  ~ ················································································································ at  11:52:30
❯ asdf plugin update php
Updating php to master
Already on 'master'
Your branch is up to date with 'origin/master'.
  ~ ····································································································· took  17s at  11:52:59
❯
But in the end, I still get the same issue: "No versions installed". I don't know where I can find a documentation about this issue.
Any ideas? Thank you
I has the same problem.
It was missing library, the following command solved it.
yay -S libpng

xdebug profiler laravel 5.5 windows empty grindfile

I am trying to profile Laravel 5.5 app on Windows 8.1 machine with xdebug 2.5.5 php version 7.0.0. php is running as cgi
Debugging works excellent i can debug but the profiler files are filled with this Laravel error (this is only with Laravel app, in simple php file profiling works fine):
version: 1 creator: xdebug 2.5.5 (PHP 7.0.15-dev)
cmd: D:\www\laravel55\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php
part: 1
positions: line
events: Time
fl=(1)
fn=(2770) php::error_get_last
122 0
fl=(1)
fn=(74)
122 0
fl=(88)
fn=(2771) Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown
120 73
cfl=(1)
cfn=(2770)
calls=1 0 0
122 0
cfl=(1)
cfn=(74)
calls=1 0 0
122 0
I have tried with xdebug 2.5.5 php version 7.1.9. same thing.
This are xdebug settings:
[Xdebug]
zend_extension="D:\AppServ\xdebug\php_xdebug-2.5.5-7.1-vc14-nts.dll"
xdebug.remote_enable=1
;xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable_trigger_value=1
xdebug.remote_autostart=1
xdebug.profiler_output_dir="D:\AppServ\xdebug\tmp"
xdebug.idekey="PHPSTORM"
The grid file is probably empty because it is overwritten several times in the same request.
You can add the timestamp + script location into the filename to prevent this:
xdebug.profiler_output_name = "cachegrind.out.%t-%s"

No oci8 module in phpinfo()

I try to set up connection with oracle database, but I still can't even set up the module. I have rhel 7. 2 server, and I followed whole tutorial for setting up oracle instantclient and configured it with php. One thing I completely don't understand is that oci8 module displays after php -i execution:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.3
Revision => $Id: 59f993160cf983dd24bb391b68a65a17303d2dba $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
But there is no such module in phpinfo() inside the script. How to fix it?
PHP Version 7.0.13
Server Apache (httpd)
LD library path:
[![enter image description here][2]][2]
The common problem would be that LD_LIBRARY_PATH isn't set for Apache.
Try adding it to /etc/sysconfig/httpd like:
LD_LIBRARY_PATH=/full/path/to/oracle-client
If I have my versions right, this version of Apache (i) doesn't like the export keyword for setting variables (ii) requires a full path since it won't expand environment variables. If I'm wrong, try either or both of those.
There is a lot of information about setting the environment in the free Underground Oracle & PHP Manual, see, for example 'Setting Oracle Environment Variables for Apache' on p 108
You say you followed 'whole tutorial'. There are many tutorials. I'd recommend Oracle's installation instructions.
The answer is:
setsebool -P allow_execstack 1
You also can enable executable stack for only oci8.so with:
execstack -c /usr/lib64/php/modules/oci8.so
https://serverfault.com/questions/314336/centos-6-php-can-not-load-gdchart-so-and-oci8-so-compiled-by-me
make sure that the oci8.so is in the php extension folder
in centos is /usr/lib64/php/modules
in ubuntu xammp is /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
cd <extension folder >
sudo chmod 755 oci8.so
It works for me after
ps ax | grep "fpm"
check the pid of "php-fpm: master process"
sudo kill -9 <pid>
start php-fpm again
sudo service php-fpm start
inspired by https://stackoverflow.com/a/21693610/2538630

Yii 1.1.12 : How to confiure OpCache : I upgraded PHP from 5.3 to 5.5

I am using Yii 1.1.12 and recently upgraded my PHP from 5.3 to 5.5 and have found that APC is no longer to be used because OpCache has been made part of PHP5.5. In my Yii main.config file, I have the following entry:
'cache'=>array(
'class'=>'system.caching.CApcCache',
),
Two questions:
I am not able to find what should I change the above entry to so
that Yii takes it as its cache? I am extensivly using following in my code
Yii::app()->cache->set('some data to be cached', $CACHE_VARIABLES);
$get_var=Yii::app()->cache->get($CACHE_VARIABLES);
Am I on the right track or missing
something else?
Output of PhpInfo shows following Zend Opcache variables (Local and Master values are mentioned in front of each varaible:
Zend OPcache
Opcode Caching Up and Running
Optimization Enabled
Startup OK
Shared memory model win32
Cache hits 731
Cache misses 144
Used memory 4487992
Free memory 62545312
Wasted memory 75560
Cached scripts 138
Cached keys 261
Max keys 3907
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli On On
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 0 0
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 4 4
opcache.load_comments 0 0
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 2000 2000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 64 64
opcache.mmap_base no value no value
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 2 2
opcache.revalidate_path Off Off
opcache.save_comments 0 0
opcache.use_cwd On On
opcache.validate_timestamps On On
Thanks.

PHP 5.4 & Laravel Class 'Memcached' not found

I realize there are about 10 of these questions out there but none fit me completely.
Steps completed:
Installed memcache
installed php memcache module
updated laravel config to use memcache
Restarted server
php info results:
memcache.allow_failover 1 1
memcache.chunk_size 8192 8192
memcache.default_port 11211 11211
memcache.default_timeout_ms 1000 1000
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.max_failover_attempts 20 20
memcached-tool results:
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 14
bytes_written 1096
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 0
cmd_get 0
cmd_set 0
cmd_touch 0
conn_yields 0
connection_structures 6
crawler_reclaimed 0
curr_connections 5
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 0
delete_misses 0
evicted_unfetched 0
evictions 0
expired_unfetched 0
get_hits 0
get_misses 0
hash_bytes 524288
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 2.0.21-stable
limit_maxbytes 268435456
listen_disabled_num 0
lrutail_reflocked 0
malloc_fails 0
pid 12022
pointer_size 64
reclaimed 0
reserved_fds 20
rusage_system 0.043400
rusage_user 0.065101
threads 4
time 1421438137
total_connections 7
total_items 0
touch_hits 0
touch_misses 0
uptime 2607
version 1.4.21
It is in php -m as "memcache"
However, when i go into php artisan tinker and try to do any caching I get the typical Fatal error: Class 'Memcached' not found in vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php on line 44
TL;DR;
I have confirmed install of memcache through multiple methods. Confirmed the module for php is installed. Still not allowing me to use memcached class.
If you are in a ubuntu environment, try to install Memcached with this:
sudo apt-get install php5-memcached
After that restart your server with
sudo service lighttpd restart
or
sudo service apachectl2 restart
or
sudo service nginx restart
Memcache and Memcached are two different PHP extensions. Memcache is the older deprecated one. Memcached is a much newer and fully supported extension.
Check out http://pecl.php.net/package/memcached
You may need to also install libmemcached https://launchpad.net/libmemcached/+download
apt-get install php-memcached
Solved the issue for "Class MemCached not found" coming from Laravel.
In Laravel/Lumen 5.4 just replace the CACHE_DRIVER=file in .env file, the artisan command will work perfectly, But you will not get all the command as same as laravel.

Categories