Email MPDF pdf attachment using swift mailer

In this post, we try to send a PDF (generated using MPDF PHP library) attachment, using Swift mailer.

Example code:

FacebookTwitterGoogle+LinkedInEmailShare

javascript open popup window full screen

Here i present an easy way to open a popup window as a new tab (full screen) in your browser:

FacebookTwitterGoogle+LinkedInEmailShare

javascript open new tab and close it

It is very easy to open a new tab and close it with javascript. Refer to the code below:

FacebookTwitterGoogle+LinkedInEmailShare

php redirect to another domain

Suppose you have moved your site to a new domain (same server), then all the links related to the old site would be lost, including those bookmarked by your users.

In order to prevent showing 404 not found to the user, you can include a condition in your index.php file as below, to redirect the user to the corresponding page on the new site. You should include this code in the starting page of your application (normally index.php).

Note that you can also use a .htaccess file to perform redirection, as discussed here.

FacebookTwitterGoogle+LinkedInEmailShare

Implement a daily work logger application with php

I am presenting here, one of my recent php applications, that i developed in my free time.
This application enables you to log your daily work at your office. Just copy this application to your localhost and you are good to go.

Features of this application include add/edit/search entries, send email to any user with the weekly entries, etc. You can use the application as a diary script or an event calendar.

Download the application from github.

Don’t forget to modify the settings in config.php file.

FacebookTwitterGoogle+LinkedInEmailShare

HTTP Basic Authentication example

It is very easy to implement the basic HTTP authentication in your php web application.
Suppose you want to force the users to provide authentication credentials, when they visit a web page in your application. You can do that as easy as below code:

FacebookTwitterGoogle+LinkedInEmailShare

Upgrade php version on CentOS

In this post, i will list the steps required to update the php version from 5.3 to 5.4 or 5.5 on a CentOS Linux server, assuming that you have ROOT access to it.

First, go to this repo link RPM package list page.

There, you can choose to download the RPMS for php version 5.4, or 5.5, and move them to your server.
Not all the RPMs are required for your php installation, but the most common ones are: common. cli, gd, mbstring, mysql, pdo, mcrypt, etc. Here is a list of steps for installing few important RPM packages for PHP 5.5:

Once you have run the above commands, restart the Apache server and verify the PHP version. Done :)

FacebookTwitterGoogle+LinkedInEmailShare

Requests PHP Library

Recently i came across a fantastic PHP library for making HTTP calls to external URLs or web services.
The library is: Requests.

It can support HTTP calls of type: GET, POST, PUT, DELETE, etc. Here i am presenting an example of GET and POST, using the library. The best thing i liked about this library is that we can get the status code of the response and use it to determine the success of our request. If status code is 200, it means the request is Successful.

FacebookTwitterGoogle+LinkedInEmailShare

hosting web tutorials