Few function of ladybug debugger not working in symfony2 php app - php

I am using this
https://github.com/raulfraile/LadybugBundle
They have three functions
ld($var1[, $var2[, ...]]): shortcut for ladybug_dump
ldd($var1[, $var2[, ...]]): shortcut for ladybug_dump_die
ldr($format, $var1[, $var2[, ...]]): shortcut for ladybug_return
First two are working but for third it says undefined function
Also i tried this to dump json then i also get error
ld(json_decode($jsonContent, true));
and i get this
UndefinedFunctionException: Attempted to call function "bccomp" from
namespace "Ladybug\Type" in
/var/www/html/site/Symfony/vendor/raulfraile/ladybug/src/Ladybug/Type/FloatType.php
line 115

The bccomp() function needs the php BC Math extension.
These functions are only available if PHP was configured with
--enable-bcmath .
The Windows version of PHP has built-in support for this extension
Check php -i | grep -i bcmath ...
There should be a line ...
BCMath support => enabled
... if the extension is enabled. Otherwise you'll probably need to recompile php with --enable-bcmath.

Related

PHP sem_get() does not work

I am trying to use semaphores on php but cannot get sem_get() function to work. Here is my PHP code:
<?php
$key = 123567;
$maxAcquire = 1;
$permissions = 0666;
$autoRelease = 1;
//it gives the error on the line below
$semaphore = sem_get($key, $maxAcquire, $permissions, $autoRelease);
sem_acquire($semaphore);
echo "hello world!";
sem_release($semaphore);
?>
When I try to run it with:
php semaphore.php
It prints this error:
PHP Fatal error: Uncaught Error: Call to undefined function sem_get()
in /root/semaphore.php:8
Stack trace:
#0 {main}
thrown in /root/semaphore.php on line 8
I am working on Arch Linux with PHP 7.0.3 (cli). I guess the solution is so simple but I couldn't find a way to fix it. If you could help me, I would appreciate it. Thanks.
Support for semaphores is not a standard feature of php.
It has to be activated via compiler --enable-sysvsem option when creating the php binary.
See explanation in manual: http://php.net/manual/en/sem.installation.php
Thank you all! I uncommented the line :
extension=sysvsem.so
on php.ini and it worked!
The semaphore extension is not available by default, as stated in the docs:
Support for this functions are not enabled by default. To enable System V semaphore support compile PHP with the option --enable-sysvsem . To enable the System V shared memory support compile PHP with the option --enable-sysvshm . To enable the System V messages support compile PHP with the option --enable-sysvmsg .
If you are on a hosted server, then that hosting service probably does not offer this.
Have a look at the docs. It feels like you do not have installed php with semaphores properly. Have a look at the installation instructions.

mb_detect_encoding() missing in PHP?

Using PHP 5.6.13 Windows CLI from http://windows.php.net/download#php-5.5, this:
include 'simple_html_dom.php'; //V1.5
$html = file_get_html('http://google.com');
fails with
Call to undefined function mb_detect_encoding()
and SO suggests this is due to the multibyte string extension missing. Indeed phpinfo() says
Zend Multibyte Support => disabled
which is is a surprise and disappointment.
What's the remedy? I want to remain with an official build.
The build package from windows.php.net contains everything you need to run the mbstring extension; it's just not enabled by default.
use <?php echo get_cfg_var('cfg_file_path'); to check which php.ini you have to edit
make sure the extension_dir=... directive points to the {yourPHPDir}/ext directory
add or uncomment* the line extension=php_mbstring.dll
(if php runs as a httpd module: restart the webserver; not the case here)
*) any line starting with a ; or (before php 7) # is concidered a comment.

can't compile php 5.5.13 with zlib (MVS)

I have put the zlib_a.lib on deps/lib and still when I configure return me that:
Checking for library zlib_a.lib;zlib.lib ...
WARNING: zlib support can't be enabled, zlib is missing
what I'm need to do for compile php with zlib? I use visual studio 2013
i have put zlib_a.lib under deps\lib but nothing
I resolved just by adding
--with-extra-libs=deps\lib --with-extra-includes=deps\include
I put zlib_a.lib into deps\lib and on deps\include I put zlib.h

WSO2 WSF/PHP installation problems (C devs help needed)

I'm trying to install WSO2 WSF/PHP extension to use SOAP with WSSE.
I was having problems when I was compiling sources, I needed to checkout trunk (instead of tag 2.1) from their repository, couple of times I fixed php 5.4 compatibility issues in source codes, finally everything compiled successfully
But when I try to enable this extension I get an error:
user#centos:~/wsf$ php -i | grep "wsf"
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/wsf.so' - /usr/lib/php5/20100525+lfs/wsf.so: undefined symbol: rampart_context_set_prv_key in Unknown on line 0
/etc/php5/cli/conf.d/20-wsf.ini,
PWD => /home/user/wsf
_SERVER["PWD"] => /home/user/wsf
I did grep on sources and found this:
user#centos:~/wsf$ grep -r "rampart_context_set_prv_key" .
./src/.svn/text-base/wsf_policy.c.svn-base: rampart_context_set_prv_key(rampart_context, env, Z_STRVAL_PP(token_val));
./src/.svn/text-base/wsf_policy.c.svn-base: if (rampart_context_set_prv_key_type (rampart_context, env, AXIS2_KEY_TYPE_PEM) == AXIS2_SUCCESS)
Binary file ./src/modules/wsf.so matches
./src/wsf_policy.c: rampart_context_set_prv_key(rampart_context, env, Z_STRVAL_PP(token_val));
./src/wsf_policy.c: if (rampart_context_set_prv_key_type (rampart_context, env, AXIS2_KEY_TYPE_PEM) == AXIS2_SUCCESS)
Binary file ./src/.libs/wsf.soT matches
Binary file ./src/.libs/wsf.so matches
Binary file ./src/.libs/wsf_policy.o matches
Binary file ./wsf_c/rampartc/src/util/.libs/librampart.so.0 matches
Binary file ./wsf_c/rampartc/src/util/.libs/librampart.a matches
Binary file ./wsf_c/rampartc/src/util/.libs/librampart.so.0.3.0 matches
Binary file ./wsf_c/rampartc/src/util/.libs/rampart_context.o matches
Binary file ./wsf_c/rampartc/src/util/.libs/librampart.so matches
./wsf_c/rampartc/src/util/rampart_context.c:rampart_context_set_prv_key(rampart_context_t *rampart_context,
./wsf_c/rampartc/src/util/rampart_context.c:rampart_context_set_prv_key_type(rampart_context_t *rampart_context,
./wsf_c/rampartc/src/util/rampart_context.c:rampart_context_set_prv_key_password(rampart_context_t *rampart_context,
Binary file ./wsf_c/rampartc/src/util/rampart_context.o matches
./wsf_c/rampartc/include/rampart_context.h: rampart_context_set_prv_key(rampart_context_t *rampart_context,
./wsf_c/rampartc/include/rampart_context.h: rampart_context_set_prv_key_type(rampart_context_t *rampart_context,
./wsf_c/rampartc/include/rampart_context.h: rampart_context_set_prv_key_password(rampart_context_t *rampart_context,
So basically I found only 1 file, wsf_policy.c which uses rampart_context_set_prv_key, but includes looks correct, and I don't know how to solve it. Any ideas?
Same Problem. Solved in the same way as in Error when trying to run security examples in wsf/php 2.1:
sudo apt-get install gcc-4.4
and then configuring wsf/php by running
./configure CC=gcc-4.4
Follow the rest of the normal installation steps and it should work.
You can also check the wsf.so library to see if it has the rampart libs linked in it by doing
ldd /usr/lib/php5/20090626/wsf.so
Also, just in case you haven't found it yet, here are the steps to compile WSF using PHP 5.4
https://wso2.org/jira/browse/WSFPHP-477
In my installation, the symbol "rampart_context_set_prv_key" is defined in the library ${wsf.home}/lib/librampart.so which is directly accessible from wsf.so thank to RPATH variable.

PHP: "independent" function to replace mime_content_type?

Is there any available, "independent" function which could replace mime_content_type()?
On my new hosting I'm getting error:
Fatal error: Call to undefined function mime_content_type() in download.php on line 3
finfo_file doesn't work as well...
Just mimic the function in your compat.php if you have one
if(!function_exists("mime_content_type"))
{
function mime_content_type($file)
{
$open_bit = finfo_open(FILEINFO_MIME_TYPE);
return finfo_file($open_bit, $file);
}
}
The above function (FileInfo) is a PECL extension and is encouraged by PHP To use as an alternative, if you do not have the extension installed you can do the following:
Find the url to the latest version of fileinfo from http://pecl.php.net/package/Fileinfo
Download, compile and install
Run the following commands
wget http://pecl.php.net/get/Fileinfo-X.X.X.tgz
gunzip Fileinfo-X.X.X.tgz
tar -xvf Fileinfo-X.X.X.tar
cd fileinfo-X.X.X
./configure
make
make install
Enable the extension by adding extension=fileinfo.so to your php.ini
Restart your web server and it should be working.
And then proceed as normal
As a matter of fact, there are two indepent implementations. One in http://upgradephp.berlios.de/ and one in PHP_Compat. You need the mime-magic file in either case.

Categories