<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Php on shocksolution.com</title><link>https://shocksolution.com/tags/php/</link><description>Recent content in Php on shocksolution.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 05 Jun 2020 20:14:15 +0000</lastBuildDate><atom:link href="https://shocksolution.com/tags/php/index.xml" rel="self" type="application/rss+xml"/><item><title>Testing Access to Google Bigtable</title><link>https://shocksolution.com/posts/testing-access-to-google-bigtable/</link><pubDate>Fri, 05 Jun 2020 20:14:15 +0000</pubDate><guid>https://shocksolution.com/posts/testing-access-to-google-bigtable/</guid><description>&lt;p&gt;This is a minimal PHP script that&amp;rsquo;s useful for verifying connectivity and permissions to read data from a Google Bigtable instance. Unlike some of the sparse examples in Google&amp;rsquo;s PHP SDK, this script will work for any table, and you don&amp;rsquo;t need to know anything about the structure of the table. This script tests the critical elements that need to work together to enable Bigtable access:&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;Credential file&lt;/em&gt; GRPC extension for PHP&#10;&lt;em&gt;Protobuf extension for PHP&lt;/em&gt; Scopes enabled on Compute Engine instances&lt;/p&gt;</description></item><item><title>Nginx default user changed in RedHat/CentOS package nginx-1.16.1-1.el7</title><link>https://shocksolution.com/posts/nginx-default-user-changed-in-redhat-centoos-package/</link><pubDate>Tue, 12 Nov 2019 02:58:34 +0000</pubDate><guid>https://shocksolution.com/posts/nginx-default-user-changed-in-redhat-centoos-package/</guid><description>&lt;p&gt;The &lt;a href="https://centos.pkgs.org/7/epel-x86_64/nginx-1.16.1-1.el7.x86_64.rpm.html"&gt;latest Nginx rpm (nginx-1.16.1-1.el7) from EPEL&lt;/a&gt; for CentOS/Redhat is a &lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=1750857"&gt;fairly major update, from version 1.12 to 1.16, and includes some very important fixes to address multiple CVE&lt;/a&gt;s. There is another small but critical change in the latest RPM that isn&amp;rsquo;t mentioned in the bug report. RedHat had configured nginx to run as user &amp;ldquo;apache&amp;rdquo; in past releases, but in the EPEL release on 19 October 2019, the configuration was changed to run as user &amp;ldquo;nginx&amp;rdquo;. If you ran &amp;ldquo;yum upgrade&amp;rdquo; recently (which you really need to do on a regular basis) on any system with nginx installed, you probably have a system that is affected.&lt;/p&gt;</description></item><item><title>Configuring Laravel/Lumen applications to connect to SQL database sockets</title><link>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</link><pubDate>Mon, 14 May 2018 18:58:47 +0000</pubDate><guid>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</guid><description>&lt;p&gt;The Laravel/Lumen framework documentation does not explain how to connect an application to a database using UNIX sockets instead of a TCP-based network connection. I recently had to configure the &lt;a href="https://polrproject.org/"&gt;Polr URL shortener&lt;/a&gt; (built on the &lt;a href="https://lumen.laravel.com/"&gt;Lumen microframework&lt;/a&gt; by &lt;a href="https://laravel.com/"&gt;Laravel&lt;/a&gt;) to connect to Google Cloud SQL with a UNIX socket. Since all of Polr&amp;rsquo;s configuration takes place in the &lt;strong&gt;.env&lt;/strong&gt; file, and there is no environment variable that&amp;rsquo;s specific to database sockets, this took some research. I finally found the answer in an &lt;a href="https://stackoverflow.com/questions/29305502/php-artisan-migrate-with-mamp-and-unix-socket/39509268#39509268"&gt;obscure StackOverflow response&lt;/a&gt;. Previous TCP connection: [code] DB_HOST=some-server-name DB_PORT=3306 [/code] Socket-based SQL connection: [code] DB_HOST=localhost;unix_socket=/cloudsql/cloud-project-name:us-east1:sql-instance-name [/code] This approach will work with any UNIX socket; you just need to give it the absolute path to the socket.&lt;/p&gt;</description></item><item><title>General error: 2006 MySQL server has gone away</title><link>https://shocksolution.com/posts/general-error-2006-mysql-server-has-gone-away/</link><pubDate>Tue, 10 Apr 2018 03:19:57 +0000</pubDate><guid>https://shocksolution.com/posts/general-error-2006-mysql-server-has-gone-away/</guid><description>&lt;p&gt;&amp;ldquo;MySQL Server has gone away&amp;rdquo; is a cryptic error that can be hard to troubleshoot (look at all the various responses on Stack Overflow!) Many problems can cause this error; I would like to document one specific case. In this example, the client is a PHP app using the Phalcon framework:&lt;/p&gt;&#10;&lt;div class="code-block"&gt;&#10; &lt;button class="code-copy" type="button" hidden aria-label="Copy code to clipboard"&gt;&#10; &lt;span class="code-copy-label" aria-hidden="true"&gt;Copy&lt;/span&gt;&#10; &lt;/button&gt;&#10; &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[Mon, 09 Apr 18 03:34:08 -0400][ERROR] SQLSTATE[HY000]: General error: 2006 MySQL server has gone away&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exception &amp;#39;PDOException&amp;#39; with message &amp;#39;SQLSTATE[HY000]: General error: 2006 MySQL server has gone away&amp;#39; in /path/to/ModelBase.php:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Stack trace:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;#0 [internal function]: PDOStatement-&amp;gt;execute()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;#17 {main}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&lt;p&gt;This error can be tricky to troubleshoot. I looked in three logs:&lt;/p&gt;</description></item></channel></rss>