Date: Fri, 1 Feb 2019 17:31:40 -0800 From: Doug Hardie <bc979@lafn.org> To: questions@freebsd.org Cc: Mark Moellering <markmoellering@psyberation.com> Subject: Re: Problems with JSON and PHP Message-ID: <5B1444AE-5241-4422-B6BA-5CE138921701@mail.sermon-archive.info> In-Reply-To: <0792A559-EDF6-49F2-889D-4D99762FD6EC@mail.sermon-archive.info> References: <C71BB378-7DC7-4C6B-83AE-21C44BA240EE@mail.sermon-archive.info> <CAA0uU3VJLXetWaeVr1CntGAnjFOyWQj0EyjB-W1ri3nJCHXeAA@mail.gmail.com> <BA63BD50-B678-4B72-82B3-8800E9C210F3@boosten.org> <CAA0uU3XR4LMBdHzTFq0tmdHmKzpsSO9F_AuMoryBrTA0%2BG2%2BFw@mail.gmail.com> <0792A559-EDF6-49F2-889D-4D99762FD6EC@mail.sermon-archive.info>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 1 February 2019, at 14:26, Doug Hardie <bc979@lafn.org> wrote:
>
>> On 1 February 2019, at 07:24, Mark Moellering <markmoellering@psyberation.com> wrote:
>>
>> On Fri, Feb 1, 2019 at 10:17 AM <freebsd@boosten.org> wrote:
>>
>>>>> test# more /usr/local/www/apache24/data/test.php
>>>>> <?php
>>>>> print "Hello world";
>>>>>
>>>>> $myObj = (object) array();
>>>>> $myObj->name = "John";
>>>>> $myObj->age = 30;
>>>>> $myObj->city = "New York";
>>>>>
>>>>> $myJSON = json_encode($myObj);
>>>>>
>>>>> echo $myJSON;
>>>>> ?>
>>>>>
>>>>>
>>>>> I use php and my biggest complaint is the way it handles errors. I
>>> think
>>>> what is happening is that your Object Definition has a syntax error but
>>> php
>>>> is complaining about the json_encode.
>>>> I believe (from the php.net docs) that it should be
>>>>
>>>> $myObj = new stdClass();
>>>>> $myObj->name = "John";
>>>>> $myObj->age = 30;
>>>>> $myObj->city = "New York";
>>>>>
>>>>
>>>
>>> Don’t believe that’s actually the issue, since the supplied test.php works
>>> like charm for me, either in my browser (through apache) or via command
>>> line.
>>>
>>> If it were the declaration, the command line would fail as well.
>
> The initial issue is with a very large package. The example I provided was the simplest I could come up with that showed the issue. I ran php -init and the output (partial) was:
>
> Server API => Command Line Interface
> Virtual Directory Support => disabled
> Configuration File (php.ini) Path => /usr/local/etc
> Loaded Configuration File => /usr/local/etc/php.ini
> Scan this dir for additional .ini files => /usr/local/etc/php
> Additional .ini files parsed => /usr/local/etc/php/ext-18-session.ini,
> /usr/local/etc/php/ext-20-curl.ini,
> /usr/local/etc/php/ext-20-filter.ini,
> /usr/local/etc/php/ext-20-gd.ini,
> /usr/local/etc/php/ext-20-hash.ini,
> /usr/local/etc/php/ext-20-json.ini,
> /usr/local/etc/php/ext-20-mbstring.ini,
> /usr/local/etc/php/ext-20-mcrypt.ini,
> /usr/local/etc/php/ext-20-mysqli.ini,
> /usr/local/etc/php/ext-20-openssl.ini,
> /usr/local/etc/php/ext-20-xdebug.ini,
> /usr/local/etc/php/ext-20-xml.ini,
> /usr/local/etc/php/ext-20-zip.ini,
> /usr/local/etc/php/ext-20-zlib.ini
>
> running via the web server the info.php file gives (reformatted to look like the above):
>
> Configuration File (php.ini)
> Path /usr/local/etc
> Loaded Configuration File /usr/local/etc/php.ini
> Scan this dir for additional .ini files /usr/local/etc/php
> Additional .ini files parsed
> /usr/local/etc/php/ext-18-session.ini,
> /usr/local/etc/php/ext-20-curl.ini,
> /usr/local/etc/php/ext-20-filter.ini,
> /usr/local/etc/php/ext-20-gd.ini,
> /usr/local/etc/php/ext-20-hash.ini,
> /usr/local/etc/php/ext-20-json.ini,
> /usr/local/etc/php/ext-20-mbstring.ini,
> /usr/local/etc/php/ext-20-mcrypt.ini,
> /usr/local/etc/php/ext-20-mysqli.ini,
> /usr/local/etc/php/ext-20-openssl.ini,
> /usr/local/etc/php/ext-20-xdebug.ini,
> /usr/local/etc/php/ext-20-xml.ini,
> /usr/local/etc/php/ext-20-zip.ini,
> /usr/local/etc/php/ext-20-zlib.ini
>
> They both use the same ini file for json. I don't see any differences between them.
I found the problem. The following lines were missing in http.conf:
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
Somehow during the installation process that file got replaced by a generic copy and those lines vanished. The way I found that was by setting up yet another test server and it worked. Then compared the various config files.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5B1444AE-5241-4422-B6BA-5CE138921701>
