المشاركات

How to Install Composer on Windows with XAMPP

صورة
Now-a-days, many modern php frameworks like laravel, symfony, codeigniter and other libraries use the composer to manage their dependencies. So you need composer to install them on your machine. In case you don't know, Composer is the tool for dependency management in php . It allows you to declare the dependency libraries and packages required for a project and it will install, update and manage them for you. Composer will never maintain anything globally by default but rather on per-project basis. You need PHP 5.3.2 and above to use Composer. So make sure the system requirements are met before installing it on your machine. In addition, you must also make some changes to the php settings to make it work. Change Settings on php.ini: I hope you have XAMPP installed already on your machine. So before composer installation, do the following changes on your php.ini file. Go to [path-to-xampp]/php folder and open php.ini file. Locate the below lines one by one and remove th...

How to Change Apache and MySQL Port Number in XAMPP Localhost

صورة
Hi! I'm going to show you how to change the apache and mysql port number in xampp localhost . In case you wonder why you should change the port number of a web server, here is the answer. It's not unlikely for you to run multiple PHP versions on a same machine or to run IIS or JBoss simultaneously with Apache. When you start a web server, it occupies the default HTTP port '80'. If you try to run the second one, it will fail since the port is already occupied. So unless you change the port for the latter, you can't run more than one web server at once. Below we will see the ways to change the port no. for apache and mysql. To Change Apache Port Number: Stop Apache server and exit XAMPP control panel if it is already running. First you must change the HTTP port. Go to [path-to-xampp-folder]/apache/conf folder and open http.conf file. The default port for Apache is '80'. Unless you have changed it, this is the port number you must replace. Now look f...

How to Convert PDF to JPEG Image in PHP

صورة
Hi! Today let's see how to convert pdf to jpeg in php using imagick . PHP offers some good native extensions for image processing. Imagick is one of those extensions with which we can easily create JPEG images from pdf without the need for third-party tools. The library does not need installation since it comes built-in with PHP. You just have to instantiate the class and use it. Plus it provides several customization options to create images. I suggest you to refer the official documentation for the complete list of functions. PHP - Convert PDF File to JPEG: Imagick is the native php extension to create and process images using the ImageMagick API . To covert the pdf into jpeg with imagick, you must first read the image from the pdf file and then write it into an image. The following example converts all the pages in a pdf file into jpeg images. <?php $imagick = new Imagick(); $imagick->readImage('mypdf.pdf'); $imagick->writeImages('myimage.jpg', fa...

How to Create Custom Library in CodeIgniter

صورة
Hi, today let's see how to create custom library in codeigniter . CodeIgniter offers a rich set of libraries and helpers for robust application development. In general, a library is a class file used to group similar functionalities into a single file. Now we can do the same with helper but the libraries have their own object to store relevant data. Below I'll show you how to create your own class libraries in CI. You must store these library files inside the 'application/libraries' folder. This will keep them separate from the native libraries of the framework. CodeIgniter - Create Custom Library: CodeIgniter is a flexible MVC framework and allows you to, Create new custom libraries. Extend existing libraries to include additional functionalities to them. Replace native libraries completely with your own version. I'm going to show you an example where I create a custom library to export the database table as a json string. STEP-1) Create a library named...

How to Import CSV File into MySQL with LOAD DATA INFILE

صورة
I tried to import a csv file into mysql with php script . It is a simple solution if you have a small set of data to import. But if you have hundreds of thousands of records, don't even think about it. You need something different to read through a large dataset quickly. MySQL's LOAD DATA INFILE command works like a charm and can be executed from the command line. Using LOAD DATA INFILE allows you to load csv or any other delimited data file to the mysql table with a single command. It comes with several options and we will see below what they are and how to use them to import the csv data set into the mysql table. Using LOAD DATA INFILE Command: The LOAD DATA INFILE command in mysql loads data from a file into the table at high speed. The file path specified must be absolute or relative. 1. Importing CSV File into MySQL: Let's say we have a mysql table 'customers' with the following structure. MySQL Table: Customers CREATE TABLE `customers`( `id` INT...

How to Add Select All Options to jQuery Select2 Plug-in

صورة
Hi, in this post let's see how to add select all options to jQuery Select2 plugin . Select2 is an excellent alternative to the standard HTML selection box that supports all its functions and provides greater flexibility. The plug-in is easy to setup and use. It supports multiple selection options where the selected elements will be added as pills to the top text box. You can also tag, search and load remote data-sets to select2 control. Below we will see how to use select2 in your web projects, and select all options at once by ticking a check box using jquery. How to Use Select2 jQuery Plug-in? To implement Select2 plug-in in your projects, create a regular drop-down box with html markup as usual. HTML: <select id="states" style="width:300px"> <option>Alaska</option> <option>Arizona</option> <option>California</option> <option>Florida</option> <option>Hawaii</option> ...

Send HTML Email in PHP via SMTP

صورة
Hi! Welcome to Koding Made Simple . Today we'll see how to send html email in php . PHP's mail() function is simple and effective and let you send emails with text/html contents and with attachments. Though it has some shortcomings compared to other mailer libraries like PHPMailer , it does the job and comes in-built with PHP package. Plain text emails are good enough, but the ability to send html emails is more powerful in email marketing and other promotions. HTML emails include html tags and let you add images, format texts and other eye-catching call-to-action buttons etc. But you have to add additional headers for mailing them. Using SMTP for Sending Email You can send mails via third party Mail Servers but you need authentication first. That is if you want to send email via Gmail in php, then you must have a working gmail account and provide the accounts email-id and password for authentication. We'll see how to set up the php configuration for sending ema...