An introduction to new php 7 book

php 7

php 7


I had started writing a well documented book on PHP 7 in the month of March but I’d to leave the project unfinished as situation demanded.
I’m eager to go back to my unfinished job. Before that I thought it would be good for my readers to give them a glimpse of how I had started it.

Note from Author

I always love to write for the beginners. I love the innocent moments of bringing few new things to my dearest readers. And this time I’ve done it by taking a completely different approach. You build web applications and learn php 7 simultaneously.
Continue reading “An introduction to new php 7 book”

How to become a good PHP developer

I want to answer this question from a beginner’s perspective. You’re reading this article because you’re a PHP developer with little knowledge and you want to make ‘coding as your forte’.

php developer

php developer

Closed or Open?

I’ve seen two sides of server side scripting. I had started learning PHP and MySQL much before I tried coding in C# and ASP.NET. I had not been developing with ASP.NET for long because I’d to leave it. Was it destiny? Actually I didn’t like the closed source. That was the real reason. Besides it was not my profession. I was not a professional PHP developer at the beginning. I was a data-journalist who wanted to be an Author and Ethical Hacker.
Continue reading “How to become a good PHP developer”

Beginning Laravel: A beginner’s guide to application development with Laravel 5.3

Learn Laravel quickly and efficiently. Add more power to your PHP skill. This book will guide you to learn one of the most popular PHP framework.
begiining-laravelBeginning Laravel

With Real World Code Example

Learn about dependency injection, interfaces, service providers, SOLID design, and more with practical and real-world code examples.
Continue reading “Beginning Laravel: A beginner’s guide to application development with Laravel 5.3”

Why WordPress for PHP Developers?

For PHP developers who want to create applications quickly but efficiently, WordPress is the best choice.
I had worked with other PHP frameworks like Laravel and Codeigniter before and found them extremely time consuming. I tasted Drupal also.

In web development you ultimately handle with content or data. And this volume of data is becoming enormous with the passage of time. It has many titles, categories, sub-categories, sub-sub-categories and you may dig deeper.

This is big data.

The simplicity of WordPress makes this job absolutely fun with little coding. If you love to code then there is Laravel. You’ll have plenty of chances to code but it’ll take time.

An application that takes one month to be formed in Laravel, may take less than one week in WordPress.

I give you a very simple example.

It took less than one hour to build a full fledged web application with WordPress where I used four different themes. I just Bootstrapped them. look at the pages first!

The first one is Home page.

why wordpress

why wordpress

The second one is a Sample Page.

why wordpress

why wordpress

The Third one is a Generic content (Here your choice is simply endless)

why wordpress

why wordpress

And Lastly for any news oriented posts I chose a completely different styling with a sidebar where I can add any widgets any time.

why wordpress

why wordpress

You just cannot imagine how simple the total operation was! It took less than one hour with few WordPress functions like this:

get_header(); get_footer(); get_sidebar(); bloginfo('stylesheet_url'); wp_list_pages(array('title_li' => '', 'exclude' => 4));


May be I’m missing one or two functions. But It’s true that it really does not take much. For getting contents on your page or post, the main WordPress functions you need are also very simple.
They are like this:

if ( have_posts() ) : while ( have_posts() ) : the_post();
the_permalink(); the_title(); the_time('l, F jS, Y'); the_content(); 
endwhile; else:
_e('Sorry, there are no posts.');
endif;

The ‘functions.php’ file is little bit longer, but less than any PHP framework single page code!


// ADD CUSTOM POST TYPE
add_action('init', 'create_post_type');
function create_post_type() {

register_post_type('generic-content',
array(
'labels' => array(
'name' => __('Generic Content'),
'singular_name' => __('Generic Content')
),
'public' => TRUE,
'has_archive' => true
));

}

function post_movie_scripts() {

if(is_post_type_archive('movies')){

wp_enqueue_style('customstyle', get_template_directory_uri(). '/custom/custom-style.css', 'style');

}

}
add_action( 'wp_enqueue_scripts', 'post_movie_scripts' );

function startboot_scripts() {

wp_register_script('my_amazing_script', get_template_directory_uri() . '/startboot/vendor/jquery/jquery.min.js', array('jquery'), true);
wp_register_script('my_amazing_script', get_template_directory_uri() . '/startboot/vendor/bootstrap/js/bootstrap.min.js', array('jquery'), true);

wp_register_script('my_amazing_script', get_template_directory_uri() . '/startboot/vendor/scrollreveal/scrollreveal.min.js', array('jquery'), true);
wp_register_script('my_amazing_script', get_template_directory_uri() . '/startboot/js/creative.min.js', array('jquery'), true);

wp_register_script('min', get_template_directory_uri() . '/custom/lib/jquery/jquery.min.js', array('jquery'), true);
wp_register_script('bootstrap', get_template_directory_uri() . '/custom/lib/bootstrap/js/bootstrap.min.js', array('jquery'), true);

wp_register_script('new-age', get_template_directory_uri() . '/custom/js/new-age.min.js', array('jquery'), true);

wp_enqueue_script('startboot_script');

//wp_enqueue_style('news', get_template_directory_uri(). '/blog/blog-style.css', 'style');

if (is_page(4)) {

wp_enqueue_style( get_template_directory_uri(). '/style.css', 'style' );

}

elseif (is_page(array(2))) {

wp_enqueue_style('customstyle', get_template_directory_uri(). '/custom/custom-style.css', 'style');

}

elseif (is_page(7)) {

wp_enqueue_style('customstyle', get_template_directory_uri(). '/custom/custom-style.css', 'style');

}

/*
elseif (is_page(array(14))) {

wp_enqueue_style('animate', get_template_directory_uri(). '/hydrogen/css/animate.css', 'style');
wp_enqueue_style('icommon', get_template_directory_uri(). '/hydrogen/css/icomoon.css', 'style');
wp_enqueue_style('magnific', get_template_directory_uri(). '/hydrogen/css/magnific-popup.css', 'style');
wp_enqueue_style('salvattore', get_template_directory_uri(). '/hydrogen/css/salvattore.css', 'style');
wp_enqueue_style('style', get_template_directory_uri(). '/hydrogen/css/style.css', 'style');

}
*/
else {

//wp_enqueue_style('customstyle', get_template_directory_uri(). '/custom/custom-style.css', 'style');

wp_enqueue_style('news', get_template_directory_uri(). '/blog/blog-style.css', 'style');
}
}

add_action( 'wp_enqueue_scripts', 'startboot_scripts' );

function boot_scripts() {

if (is_page(16)) {

wp_enqueue_style('WP Bootstrap', get_template_directory_uri(). '/bootstrap/boot-style.css', 'style');

}

}
add_action( 'wp_enqueue_scripts', 'boot_scripts' );

if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '',
'after_widget' => '',
'before_title' => '

',
'after_title' => '

',
));

register_taxonomy( 'sample-taxonomy', 'post', array( 'label' => 'Sample Taxonomy'));

Look at the main ‘style.css’ code, this is unbelievable:

@import url('startboot/vendor/bootstrap/css/bootstrap.min.css');
@import url('startboot/vendor/font-awesome/css/font-awesome.min.css');
@import url('startboot/vendor/magnific-popup/magnific-popup.css');
@import url('startboot/css/creative.min.css');

body {

}

.home-content {

margin: 10px;
padding: 10px;

}

.footer-content {

}

The Other related style-sheet coding are equally simple and elegant.

I hope this post will help PHP developers to decide which they really need to work faster to give more output in less time.

I know your job is demanding.

Adapter Pattern in PHP

Can we Adapt SMS into MAIL?
Now we’re going to do an impossible task.
Are you prepared?
Can we start?
This chapter is about the adapter pattern. It’s one of the design patterns that you’re currently on. Let us start with a real world example.
You know that internet connection is absolutely necessary for sending emails. Is it true in the real world? You’d say, well, I know that. An internet networking is a must.

Continue reading “Adapter Pattern in PHP”

Chain of responsibility in php

Let us see how Responsibility can be Unchained!
In object-oriented design, the chain-of-responsibility pattern belongs to behavioral design patterns segment. The simplest example contains a person using ATM. He’s entering pin, receiving payment and receipts etcetera.
What is behavioral design pattern? They are a type of design patterns that generally identify communicating objects.
You may ask, what kind of objects we’re talking about? These objects have common communication patterns between them. While communicating they must realize that patterns.

Continue reading “Chain of responsibility in php”

Decorator Patterns in PHP

When we want to add additional features to our existing classes we generally use decorator pattern.
Do you find this definition useful?
I believe the answer will be NO.
It says about only adding new features. It doesn’t say about how you will use that. Will you add the features by simply hard coding or you’ll add them in the run time.
That’s a pretty big difference.
Why?
Let us consider a simple example where we are talking about a hosting company. A typical hosting company sells hosting services and sometimes they also provide template designing.
Let’s design a pretty basic scenario.

Continue reading “Decorator Patterns in PHP”

Environment in Laravel 5.3

Laravel comes with many stunning features. One of them is definitely database migrations. In the next chapter we’ll discuss about migration in detail.
Before that we need to understand our environment properly. What is environment in Laravel? If you look at the document root you will find an ‘.env’ file. It basically says about the database connections. Where would we get that default database set up file? In the ‘config’ folder, we have a ‘database.php’ file. Open it up and see the content.

Continue reading “Environment in Laravel 5.3”

Routing in Laravel 5.3

Routing, a Static Method


Routing is the concept of setting up a new URI like http://localhost:8000/hello. It will take you to a destination web page. Laravel makes it extremely simple. It’s a static method that accepts two things: an URI and an anonymous function or Closure.
In the ‘app/Http/routes.php’ it’s been defined primarily. Start your favorite text editor and open the file. What you see?
You see some code like this:

Route::get('/', function () {
return view('welcome');
});

Continue reading “Routing in Laravel 5.3”

Composer-revolution and library of codes

Composer is a dependency management tool in PHP. For any PHP project you need to use your library of codes. Composer easily manages that task on your behalf helping you to declare those codes. You can also install or update any code in your library through composer. Please visit https://getcomposer.org for more details.
In the opening page of https://getcomposer.org, click the ‘getting started’ link.

composer home page

composer home page


In the above page you find two links – ‘locally’ and ‘globally’. It stands for two options. Suppose you don’t want to run composer globally or centrally in your system. In that case, you have to download and install composer each time for every project. But the global option is always preferable because once composer is installed in your system bin folder you can call it any time for any project.

Continue reading “Composer-revolution and library of codes”