Apache · How To · PHP · Symfony2

How to Configure a Custom php.ini file for a Website

There are a few ways to create a custom php.ini configuration directives for an apache website.

Create a phpinfo.php file with the following content within your document root.

View this file in your browser and look near the top for which Server API is running PHP.

If PHP is being run by CGI
If the phpinfo.php file’s output says PHP is being run by CGI, then simply place a php.ini file of your own in the site’s root directory.

If PHP is being run by Apache 2.0 Handler

If in the phpinfo.php file you see something like Server API | Apache 2.0 Handler

then use the .htaccess file to change PHP configuration settings.

Here is an example of the .htaccess Code

With Server API | Apache 2.0 Handler one may also use the Apache PHPINIDir directive to tell apache where to look for a custome php.ini file.

For this method, you will need access to the httpd.conf file or perhaps the httpd-vhosts.conf file where the apache directives for the site are configured.

Simply use the PHPINIDir directive followed by the directory where you want apache to look for the custom php.ini file. This directory is usually the document root.

Within the httpd.conf file (or httpd-vhosts), look for the directive of the site.

Then add the line: PHPINIDir /Users/Username/Sites/example.com like this (use your own directory info and site name, obviously):

PHPINIDir directive may only occur once or you will get an apache error.

Now the output of the phpinfo() function should show a value for “Loaded Configuration File” as /Users/Username/Sites/example.com.

To see this output, just take a look at the output of phpinfo.php file you made.

Look for “Loaded Configuration File” you should be able to see your custom php.ini file there.

How To · PHP · Symfony2

How to Add Current URL from Within Symfony2 Controller

I am building a REST app and wanted to include the resources “href” with every response. Being able to easily do this from with a Symfony2 Controller is very convenient.

Here’s the code:

Hope this helped you find it fast!

Backend · How To · Linux · REST · Symfony2

How to Make JSON REST POST with Curl

This is just a reference to remind myself and others how to make a JSON POST call with curl.

The JSON is in the body of the post.

I hope this is helpful to someone.