Category: PHP MySQL Development

  • Upload to FTP with PHP

    $fp = fopen(‘https://www.example.com/pdfdoc’, ‘r’); $user = “sammy”; $pass = “password”; $ftp_server = “192.168.10.10”; //should be wrapped in try catch to properly handle errors $ftp_conn = ftp_ssl_connect($ftp_server); $login = ftp_login($ftp_conn, $user, $pass); ftp_chdir($ftp_conn, ‘path/to/folder’); //can also use ftp_pwd ftp_pasv($ftp_conn, true); //passive mode ftp_fput($ftp_conn, “mydocument.pdf”, $fp, FTP_BINARY); fclose($fp); ftp_close($ftp_conn); Above code can be used to upload a…

  • Laravel Jenkins CI

    This article covers installation of Jenkins on Ubuntu server and its usage to continuously integrate a Laravel application.  Besides LAMP/LEMP stack we need to install Java, Git, Composer, and Node to successfully use Jenkins. Before starting to install this software, let’s take care of miscellaneous  stuff. Miscellaneous (can skip this). Create mysql user and database.…

  • Composer: Path Repositories

    When working on a php package it is inconvenient to push the package to github (or other repository) and then wait for the package to update using composer update.  For package development, composer has such feature as path repositories.  Let’s imagine we have a two folders on the same level:  my-app and  package.   my-app is an app — a test…

  • Running Artisan Command as a Separate PHP Process in Laravel

    In Laravel framework you can create commands and call them from php application.  One command can call another command, and another command, and so on.  But if an exception is thrown in one of the commands in this chain the whole chain breaks.  In order to avoid this problem and run each artisan command as…

  • Create WordPress User with Admin Privileges in MySQL

    INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES (‘admin’, MD5(‘password’), ‘User Admin’, ‘user@admin.com’, ‘0’); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), ‘wp_capabilities’, ‘a:1:{s:13:”administrator”;s:1:”1″;}’); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), ‘wp_user_level’, ’10’);

  • Exporting/Importing MySQL database from/to Remote Server

    Export database mysqldump -u dbuser -p databasename -h rds.amazonaws.com > backup.sql Import database mysql -u username -p -h rds.amazon.com databasename < backup.sql mysql –host=rds.amazonaws.com –user=dbuser –password=password databasename < backup.sql

  • Using PhpMyAdmin With Homestead

    Laravel Homestead includes a lot of software, but unfortunately does not have PhpMyAdmin.  You can always install it on nginx, but if you have it already on your host system (for example, as a part of xampp package), you can always configure it as a Nginx site. First of all, you need to edit your config.inc.php file.  At…

  • Magento 2 Data Migration Notes

    Recently I was assigned to do data migration from Magento 1.8.1.0 to Magento 2.1.0 In this article, I will share some points you must look out for when migrating to Magento 2. There are several things you must be aware of before you start migration: Magento 2 is a memory hog.  So, suggested 2GB RAM…

  • Contact Form Processing with PHP, MySQL, and Swift Mailer

    In this article we will take a look how to process a contact form on your web page. We will collect the data from input fields, server side validate it by checking if fields are empty, put website user’s message in the database, and send a notification email to the website owner.