simple_xml_string関数返り値が開発環境と本番環境で同じでない為に、デプロイでバグとなってしまっています。
おそらく本番環境のEC2での環境構築で足りないものがあると考えています。
開発環境
- Docker
- PHP-fpm 7.3.19
- phpinfoで simplexml support enabled確認
本番環境
- EC2 Amazon Linux 2
- PHP 7.3.17
- phpinfoではsimplexml support enabled確認
- additional .iniファイルが存在 中身は以下の1行
extension=simplexml
コード
php
1<?php 2 3$xml = <<< EOF 4<?xml version="1.0" encoding="UTF-8"?> 5<Response> 6 <Timestamp>2020-07-06T01:29:26.096Z</Timestamp> 7 <Ack>Success</Ack> 8 <Build>E1141_CORE_APILW_19170841_R1</Build> 9 <Version>1141</Version> 10 <Summary> 11 <ShippingCost currencyID="USD">24.02</ShippingCost> 12 <ImportCharge currencyID="USD">0.0</ImportCharge> 13 </Summary> 14</Response> 15EOF; 16 17$objXml = simplexml_load_string($xml, NULL, LIBXML_NOCDATA); 18 19echo "<pre>"; 20var_dump($objXml); 21echo "</pre>"; 22
出力の違い
開発環境
object(SimpleXMLElement)#34 (5) { ["Timestamp"]=> string(24) "2020-07-06T01:29:26.096Z" ["Ack"]=> string(7) "Success" ["Build"]=> string(28) "E1141_CORE_APILW_19170841_R1" ["Version"]=> string(4) "1141" ["Summary"]=> object(SimpleXMLElement)#38 (2) { ["ShippingCost"]=> string(5) "24.02" ["ImportCharge"]=> string(3) "0.0" } }
本番環境
object(SimpleXMLElement)#34 (5) { ["Timestamp"]=> string(24) "2020-07-06T01:29:26.096Z" ["Ack"]=> string(7) "Success" ["Build"]=> string(28) "E1141_CORE_APILW_19170841_R1" ["Version"]=> string(4) "1141" ["Summary"]=> object(SimpleXMLElement)#38 (2) { ["ShippingCost"]=> object(SimpleXMLElement)#40 (2) { ["@attributes"]=> array(1) { ["currencyID"]=> string(3) "USD" } [0]=> string(5) "24.02" } ["ImportCharge"]=> object(SimpleXMLElement)#33 (2) { ["@attributes"]=> array(1) { ["currencyID"]=> string(3) "USD" } [0]=> string(3) "0.0" } } }
よろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/06 02:47