This time I would like to share few Laravel quick tips, which I use and it help me to make some things faster and cleaner code.

In Routes, you can create a group within a group. Also, assign a certain middleware only to some of them.

Route::group(['prefix' => 'user', 'as' => 'user.'], function() {
 Route::get('login', 'UserController@login');
 Route::get('register', 'UserController@register');
 Route::group(['middleware' => 'auth'], function() {
   Route::get('edit', 'UserController@edit');
 });
});
Continue reading

AWS provides great services and can be easily configured to handle big traffic spikes. However, sometimes some nuance occurs when a big amount of data need to process. For example, I was using SQS in my Laravel project. We are letting the Credential Provider retrieve the credentials to access SQS service via the IAM role attached to the EC2 instance. This works great but due to the volume of traffic we get this exception thousands of times a day:

Continue reading

Here’s a function that can get the mime type of a remote file. It will also follow any redirects that are in place.


function get_url_mime_type($url)
{

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_exec($ch);
return curl_getinfo($ch, CURLINFO_CONTENT_TYPE);

}

This is fast way how to install nginx, php 5.4 and other dependencies. Use this script on your own risk.

#!/bin/bash

if ! [ $(id -u) = 0 ]; then
   echo "Please login via root!"
   exit 1

else

yum install  update

#Remi Dependency on CentOS 6 and Red Hat (RHEL) 6
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#CentOS 6.4/6.3/6.2/6.1/6/5.9 Nginx repository
cat <<EOF >/etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
EOF
#Install Nginx, PHP 5.4 and PHP-FPM
yum --enablerepo=remi,remi-test install nginx php-fpm php-common
#Install PHP 5.4 modules
yum --enablerepo=remi install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y -y
#Start Nginx HTTP server and PHP-FPM
service nginx start
service php-fpm start
#Autostart Nginx and PHP-FPM on boot
chkconfig nginx on
chkconfig php-fpm on
#Install mysql
yum install mysql mysql-server -y
service mysqld start
chkconfig mysqld on

fi

This is addon for whmcs. This addon displays user profile in chat window.

Information you will see in chat window:

  1. Client name, last name, credits, email, company name.
  2. Unpaid client invoices
  3. Client products (ex. domains, hosting)

Install

  1. Copy files to your whmcs system files (modules/addons)
  2. Go to whmcs admin panel, and go to Setup->Addon Modules.
  3. Find livehelper addon and activate it.
  4. Click configure button and enable widget on you whmcs system. Change settings by your own wishes. (you do not need to add any additional code to whmcs)

Good luck!

Continue reading

Today I will show simple, but simetimes very usefull example, how to remove empty paragrapth from your text.

My code:

<?php
$html = "abc<p></p><p>dd</p><b>non-empty</b>";
$pattern = "/<p[^>]*><\\/p[^>]*>/";
//$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";  use this pattern to remove any empty tag

echo preg_replace($pattern, '', $html);
// output
//abc<p>dd</p><b>non-empty</b>
?>

Very simple 🙂