Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

json_decode causes failures.

I am new to Zephir so I apologise if this is one of those 'should have read the docs' situation: Issue: When I use jsondecode() within a .zep file the build fails with ' undefined symbol: phpjsondecodeex in Unknown on line 0 '

My searches have revealed an optimizer for jsondecode, but optimizers are beyond me at present! I have found no other reference to jsondecode and Zephir.

This may be another clue to my problem:

Trying to use the Zephir built in functions array->merge(anotherArray) and var s = "Hello" s->length() the compiler / parser appears to work OK and installs my extension, but then I get 500 errors from Apache. Using PHP's array_merge(arrayA, arrayB) works OK, extension compiles, installs and works.

Any help appreciated.

Thanks in advance. Jonathan

edited Jan '16

I used the following sh script to install Zephir, maybe there's an issue here! :

#!/bin/bash

##########################################
# @package zephir
# @author Zeki √únal <[email protected]>
# @name zephir.sh
##########################################

####################################################################################
# Update CentOS 7
####################################################################################
sudo yum update -y
yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmcentos 7 lamp
sudo yum update -y

rpm -Uvh http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/el/releases/7/Everything/x86_64/os/re2c-0.13.5-7.el7.R.x86_64.rpm
yum install -y re2c

yum install -y httpd
chkconfig httpd on
systemctl enable httpd.service
systemctl start httpd.service

echo "Apache installed."

if ! rpm -qa | grep -qw php56w; then
    yum install -y php56w
    echo "php56w installed."
fi

if ! rpm -qa | grep -qw php56w-opcache; then
    yum install -y php56w-opcache
    echo "php56w-opcache installed."
fi

if ! rpm -qa | grep -qw php56w-common; then
    yum install -y php56w-common
    echo "php56w-common installed."
fi

if ! rpm -qa | grep -qw php56w-mysql; then
    yum install -y php56w-mysql
    echo "php56w-mysql installed."
fi

if ! rpm -qa | grep -qw php56w-pecl-memcache; then
    yum install -y php56w-pecl-memcache
    echo "php56w-pecl-memcache installed."
fi

if ! rpm -qa | grep -qw php56w-devel; then
    sudo yum install -y php56w-devel
    echo "php56w-devel installed."
fi

if ! rpm -qa | grep -qw gcc; then
    sudo yum install -y gcc
    echo "gcc installed."
fi

if ! rpm -qa | grep -qw libtool; then
    sudo yum install -y libtool
    echo "libtool installed."
fi

if ! rpm -qa | grep -qw make; then
    sudo yum install -y make
    echo "make installed."
fi

if ! rpm -qa | grep -qw git-core; then
    sudo yum install -y git-core
    echo "git installed."
fi

if ! rpm -qa | grep -qw gd; then
    sudo yum install -y gd
    echo "gd installed."
fi

if ! rpm -qa | grep -qw gd-devel; then
    sudo yum install -y gd-devel
    echo "gd-devel installed."
fi

if ! rpm -qa | grep -qw php56w-gd; then
    sudo yum install -y php56w-gd
    echo "php56w-gd installed."
fi


####################################################################################
# Install json-c
####################################################################################

git clone https://github.com/json-c/json-c.git
cd /json-c
./autogen.sh
./configure
make
make install
cd /

####################################################################################
# Install zephir
####################################################################################

git clone https://github.com/phalcon/zephir
cd zephir
./install -c
zephir help

if [ ! -f /usr/lib64/php/modules/phalcon.so ]; then

    git clone --depth=1 git://github.com/phalcon/cphalcon.git
    cd cphalcon/build
    sudo ./install

    if [ ! -L /etc/php.d/phalcon.ini ]
    then
                rm -f -r /etc/php.d/phalcon.ini
                echo "; Enable phalcon extension module" >> /etc/php.d/phalcon.ini
                echo "extension=phalcon.so" >> /etc/php.d/phalcon.ini
                echo 'date.timezone = "Europe/London"' >> /etc/php.d/phalcon.ini
    fi
    cd /
    clear
fi

service httpd restart

echo "########### Apache Installed ###########"


989
Accepted
answer

I have finally found a solution to the jsondecode issue. Being new to linux I am not sure if it is the correct solution: JSON support was shown as being available via phpinfo(), the json extension is loaded via json.ini within the php.d directory. I commented out the extension in /etc/php.d/json.ini and added 'extension=json.so' to /etc/php.ini BEFORE any other extension. This seems to have solved the jsondecode errors that I was receiving. I have further tests to do to make sure json_decode is working properly, but at least I have some progress.