Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning PHP 7
Learning PHP 7

Learning PHP 7: Build powerful real-life web applications in a simple way using PHP7 and its ecosystem.

eBook
$38.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Learning PHP 7

Chapter 1. Setting Up the Environment

You are about to start a journey—a long one, in which you will learn how to write web applications with PHP. However, first, you need to set up your environment, something that has proven to be tricky at times. This task includes installing PHP 7, the language of choice for this book; MySQL, the database that we will use in some chapters; Nginx, the web server that will allow us to visualize our applications with a browser; and Composer, the favorite PHP dependencies management tool. We will do all of this with Vagrant and also on three different platforms: Windows, OS X, and Ubuntu.

In this chapter, you will learn about:

  • Using Vagrant to set up a development environment
  • Setting up your environment manually on the main platforms

Setting up the environment with Vagrant

Not so long ago, every time you started working for a new company, you would spend an important part of your first few days setting up your new environment—that is, installing all the necessary tools on your new computer in order to be able to code. This was incredibly frustrating because even though the software to install was the same, there was always something that failed or was missing, and you would spend less time being productive.

Introducing Vagrant

Luckily for us, people tried to fix this big problem. First, we have virtual machines, which are emulations of computers inside your own computer. With this, we can have Linux inside our MacBook, which allows developers to share environments. It was a good step, but it still had some problems; for example, VMs were quite big to move between different environments, and if developers wanted to make a change, they had to apply the same change to all the existing virtual machines in the organization.

After some deliberation, a group of engineers came up with a solution to these issues and we got Vagrant. This amazing software allows you to manage virtual machines with simple configuration files. The idea is simple: a configuration file specifies which base virtual machine we need to use from a set of available ones online and how you would like to customize it—that is, which commands you will want to run the first time you start the machine—this is called "provisioning". You will probably get the Vagrant configuration from a public repository, and if this configuration ever changes, you can get the changes and reprovision your machine. It's easy, right?

Installing Vagrant

If you still do not have Vagrant, installing it is quite easy. You will need to visit the Vagrant download page at https://www.vagrantup.com/downloads.html and select the operating system that you are working with. Execute the installer, which does not require any extra configuration, and you are good to go.

Using Vagrant

Using Vagrant is quite easy. The most important piece is the Vagrantfile file. This file contains the name of the base image we want to use and the rest of the configuration that we want to apply. The following content is the configuration needed in order to get an Ubuntu VM with PHP 7, MySQL, Nginx, and Composer. Save it as Vagrantfile at the root of the directory for the examples of this book.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/trusty32"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.provision "shell", path: "provisioner.sh"
end

As you can see, the file is quite small. The base image's name is ubuntu/trusty32, messages to our port 8080 will be redirected to the port 80 of the virtual machine, and the provision will be based on the provisioner.sh script. You will need to create this file, which will be the one that contains all the setup of the different components that we need. This is what you need to add to this file:

#!/bin/bash

sudo apt-get install python-software-properties -y
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
sudo apt-get --purge autoremove -y
sudo service php7.0-fpm restart

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get -y install mysql-server mysql-client
sudo service mysql start

sudo apt-get install nginx -y
sudo cat > /etc/nginx/sites-available/default <<- EOM
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /vagrant;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files \$uri \$uri/ /index.php?\$query_string;
    }

    location ~ \.php\$ {
        try_files \$uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        include fastcgi_params;
    }
}
EOM
sudo service nginx restart

The file looks quite long, but we will do quite a lot of stuff with it. With the first part of the file, we will add the necessary repositories to be able to fetch PHP 7, as it does not come with the official ones, and then install it. Then, we will try to install MySQL, server and client. We will set the root password on this provisioning because we cannot introduce it manually with Vagrant. As this is a development machine, it is not really a problem, but you can always change the password once you are done. Finally, we will install and configure Nginx to listen to the port 8080.

To start the virtual machine, you need to execute the following command in the same directory where Vagrantfile is:

$ vagrant up

The first time you execute it, it will take some time as it will have to download the image from the repository, and then it will execute the provisioner.sh file. The output should be something similar to this one followed by some more output messages:

Using Vagrant

In order to access your new VM, run the following command on the same directory where you have your Vagrantfile file:

$ vagrant ssh

Vagrant will start an SSH session to the VM, which means that you are inside the VM. You can do anything you would do with the command line of an Ubuntu system. To exit, just press Ctrl + D.

Sharing files from your laptop to the VM is easy; just move or copy them to the same directory where your Vagrantfile file is, and they will "magically" appear on the /vagrant directory of your VM. They will be synchronized, so any changes that you make while in your VM will be reflected on the files of your laptop.

Once you have a web application and you want to test it through a web browser, remember that we will forward the ports. This means that in order to access the port 80 of your VM, the common one for web applications, you will have to point to the port 8080 on your browsers; here's an example: http://localhost:8080.

Setting up the environment on OS X

If you are not convinced with Vagrant and prefer to use a Mac to develop PHP applications, this is your section. Installing all the necessary tools on a Mac might be a bit tricky, depending on the version of your OS X. At the time of writing this book, Oracle has not released a MySQL client that you can use via the command line that works with El Capitan, so we will describe how to install another tool that can do a similar job.

Installing PHP

If it is the first time you are using a Mac to develop applications of any kind, you will have to start by installing Xcode. You can find this application for free on the App Store:

Installing PHP

Another indispensable tool for Mac users is Brew. This is the package manager for OS X and will help us install PHP with almost no pain. To install it, run the following command on your command line:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If you already have Brew installed, you can make sure that everything works fine by running these two commands:

$ brew doctor
$ brew update

It is time to install PHP 7 using Brew. To do so, you will just need to run one command, as follows:

$ brew install homebrew/php/php70

The result should be as shown in the following screenshot:

Installing PHP

Make sure to add the binary to your PATH environment variable by executing this command:

$ export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

You can check whether your installation was successful by asking which version of PHP your system is using with the $ php –v command.

Installing MySQL

As pointed out at the beginning of this section, MySQL is a tricky one for Mac users. You need to download the MySQL server installer and MySQL Workbench as the client. The MySQL server installer can be found at https://dev.mysql.com/downloads/mysql/. You should find a list of different options, as shown here:

Installing MySQL

The easiest way to go is to download DMG Archive. You will be asked to log in with your Oracle account; you can create one if you do not have any. After this, the download will start. As with any DMG package, just double-click on it and go through the options—in this case, just click on Next all the time. Be careful because at the end of the process, you will be prompted with a message similar to this:

Installing MySQL

Make a note of it; otherwise, you will have to reset the root password. The next one is MySQL Workbench, which you can find at http://www.mysql.com/products/workbench/. The process is the same; you will be asked to log in, and then you will get a DMG file. Click on Next until the end of the installation wizard. Once done, you can launch the application; it should look similar to this:

Installing MySQL

Installing Nginx

In order to install Nginx, we will use Brew, as we did with PHP. The command is the following:

$ brew install nginx

If you want to make Nginx start every time you start your laptop, run the following command:

$ ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents

If you have to change the configuration of Nginx, you will find the file in /usr/local/etc/nginx/nginx.conf. You can change things, such as the port that Nginx is listening to or the root directory where your code is (the default directory is /usr/local/Cellar/nginx/1.8.1/html/). Remember to restart Nginx to apply the changes with the sudo nginx command.

Installing Composer

Installing Composer is as easy as downloading it with the curl command; move the binary to /usr/local/bin/ with the following two commands:

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

Setting up the environment on Windows

Even though it is not very professional to pick sides based on personal opinions, it is well known among developers how hard it can be to use Windows as a developer machine. They prove to be extremely tricky when it comes to installing all the software since the installation mode is always very different from OS X and Linux systems, and quite often, there are dependency or configuration problems. In addition, the command line has different interpreters than Unix systems, which makes things a bit more confusing. This is why most developers would recommend you use a virtual machine with Linux if you only have a Windows machine at your disposal.

However, to be fair, PHP 7 is the exception to the rule. It is surprisingly simple to install it, so if you are really comfortable with your Windows and would prefer not to use Vagrant, here you have a short explanation on how to set up your environment.

Installing PHP

In order to install PHP 7, you will first download the installer from the official website. For this, go to http://windows.php.net/download. The options should be similar to the following screenshot:

Installing PHP

Choose x86 Thread Safe for Windows 32-bit or x64 Thread Safe for the 64-bit one. Once downloaded, uncompress it in C:\php7. Yes, that is it!

Installing MySQL

Installing MySQL is a little more complex. Download the installer from http://dev.mysql.com/downloads/installer/ and execute it. After accepting the license agreement, you will get a window similar to the following one:

Installing MySQL

For the purposes of the book—and actually for any development environment—you should go for the first option: Developer Default. Keep going forward, leaving all the default options, until you get a window similar to this:

Installing MySQL

Depending on your preferences, you can either just set a password for the root user, which is enough as it is only a development machine, or you can add an extra user by clicking on Add User. Make sure to set the correct name, password, and permissions. A user named test with administration permissions should look similar to the following screenshot:

Installing MySQL

For the rest of the installation process, you can select all the default options.

Installing Nginx

The installation for Nginx is almost identical to the PHP 7 one. First, download the ZIP file from http://nginx.org/en/download.html. At the time of writing, the versions available are as follows:

Installing Nginx

You can safely download the mainline version 1.9.10 or a later one if it is stable. Once the file is downloaded, uncompress it in C:\nginx and run the following commands to start the web server:

$ cd nginx
$ start nginx

Installing Composer

To finish with the setup, we need to install Composer. To go for the automatic installation, just download the installer from https://getcomposer.org/Composer-Setup.exe. Once downloaded, execute it in order to install Composer on your system and to update your PATH environment variable.

Setting up the environment on Ubuntu

Setting up your environment on Ubuntu is the easiest of the three platforms. In fact, you could take the provisioner.sh script from the Setting up the environment with Vagrant section and execute it on your laptop. That should do the trick. However, just in case you already have some of the tools installed or you want to have a sense of control on what is going on, we will detail each step.

Installing PHP

The only thing to consider in this section is to remove any previous PHP versions on your system. To do so, you can run the following command:

$ sudo apt-get -y purge php.*

The next step is to add the necessary repositories in order to fetch the correct PHP version. The commands to add and update them are:

$ sudo apt-get install python-software-properties
$ sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
$ sudo apt-get update

Finally, we need to install PHP 7 together with the driver for MySQL. For this, just execute the following three commands:

$ sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
$ sudo apt-get --purge autoremove -y
$ sudo service php7.0-fpm start

Installing MySQL

Installing MySQL manually can be slightly different than with the Vagrant script. As we can interact with the console, we do not have to specify the root password previously; instead, we can force MySQL to prompt for it. Run the following command and keep in mind that the installer will ask you for the password:

$ sudo apt-get -y install mysql-server mysql-client

Once done, if you need to start the MySQL server, you can do it with the following command:

$ sudo service mysql start

Installing Nginx

The first thing that you need to know is that you can only have one web server listening on the same port. As port 80 is the default one for web applications, if you are running Apache on your Ubuntu machine, you will not be able to start an Nginx web server listening on the same port 80. To fix this, you can either change the ports for Nginx or Apache, stop Apache, or uninstall it. Either way, the installation command for Nginx is as follows:

$ sudo apt-get install nginx –y

Now, you will need to enable a site with Nginx. The sites are files under /etc/nginx/sites-available. There is already one file there, default, which you can safely replace with the following content:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

This configuration basically points the root directory of your web application to the /var/www/html directory. You can choose the one that you prefer, but make sure that it has the right permissions. It also listens on the port 80, which you can change with the one you prefer; just keep this in mind that when you try to access your application via a browser. Finally, to apply all the changes, run the following command:

$ sudo service nginx restart

Tip

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  • Log in or register to our website using your e-mail address and password.
  • Hover the mouse pointer on the SUPPORT tab at the top.
  • Click on Code Downloads & Errata.
  • Enter the name of the book in the Search box.
  • Select the book for which you're looking to download the code files.
  • Choose from the drop-down menu where you purchased this book from.
  • Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

Summary

In this chapter, you learned how easy it is to set up a development environment using Vagrant. If this did not convince you, you still got the chance to set up all the tools manually. Either way, now you are able to work on the next chapters.

In the next chapter, we will take a look at the idea of web applications with PHP, going from the protocols used to how the web server serves requests, thus setting the foundation for the following chapters.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Set up the PHP environment and get started with web programming
  • Leverage the potential of PHP for server-side programming, memory management, and object-oriented programming (OOP)
  • This book is packed with real-life examples to help you implement the concepts as you learn

Description

PHP is a great language for building web applications. It is essentially a server-side scripting language that is also used for general purpose programming. PHP 7 is the latest version with a host of new features, and it provides major backwards-compatibility breaks. This book begins with the fundamentals of PHP programming by covering the basic concepts such as variables, functions, class, and objects. You will set up PHP server on your machine and learn to read and write procedural PHP code. After getting an understanding of OOP as a paradigm, you will execute MySQL queries on your database. Moving on, you will find out how to use MVC to create applications from scratch and add tests. Then, you will build REST APIs and perform behavioral tests on your applications. By the end of the book, you will have the skills required to read and write files, debug, test, and work with MySQL.

Who is this book for?

If you are a web developer or programmer who wants to create real-life web applications using PHP 7, or a beginner who wants to get started with PHP 7 programming, this book is for you. Prior knowledge of PHP, PHP 7, or programming is not mandatory.

What you will learn

  • Set up a server on your machine with PHP
  • Use PHP syntax with the built-in server to create apps
  • Apply the OOP paradigm to PHP to write richer code
  • Use MySQL to manage data in your web applications
  • Create a web application from scratch using MVC
  • Add tests to your web application and write testable code
  • Use an existing PHP framework to build and manage your applications
  • Build REST APIs for your PHP applications
  • Test the behavior of web applications with Behat
Estimated delivery fee Deliver to Argentina

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 29, 2016
Length: 414 pages
Edition : 1st
Language : English
ISBN-13 : 9781785880544
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Argentina

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Publication date : Mar 29, 2016
Length: 414 pages
Edition : 1st
Language : English
ISBN-13 : 9781785880544
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 153.97
Learning PHP 7
$54.99
PHP 7 Programming Cookbook
$54.99
Learning PHP 7 High Performance
$43.99
Total $ 153.97 Stars icon

Table of Contents

11 Chapters
1. Setting Up the Environment Chevron down icon Chevron up icon
2. Web Applications with PHP Chevron down icon Chevron up icon
3. Understanding PHP Basics Chevron down icon Chevron up icon
4. Creating Clean Code with OOP Chevron down icon Chevron up icon
5. Using Databases Chevron down icon Chevron up icon
6. Adapting to MVC Chevron down icon Chevron up icon
7. Testing Web Applications Chevron down icon Chevron up icon
8. Using Existing PHP Frameworks Chevron down icon Chevron up icon
9. Building REST APIs Chevron down icon Chevron up icon
10. Behavioral Testing Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.4
(10 Ratings)
5 star 40%
4 star 20%
3 star 0%
2 star 20%
1 star 20%
Filter icon Filter
Top Reviews

Filter reviews by




PinkPearl Feb 19, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent, easy to understand, start here.
Amazon Verified review Amazon
Cliente Amazon Jul 06, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book is very interesting, well written and with lots of sample code, which helps a lot to understand the different concepts that are explained across the book.I found specially interesting the Testing section and the MVC framework implementation sample.Hands on and easy to read book, definitely recommended!
Amazon Verified review Amazon
B Bonkoski Apr 07, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Goes into many areas and concepts including MVC, micro frameworks, full frameworks, testing, and many others. Very good survey coverage with highlighting some of the new features from PHP7.Disclaimer: I might be biased as the Technical Reviewer.
Amazon Verified review Amazon
bootha Apr 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Big Help
Amazon Verified review Amazon
Rattanak Chea Jul 04, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
You should have at least some fundamental programming experience to understand the concept the Author trying to convey. It is high level, yet very direct to the point with concise examples. I feel understand a lot of more what underneath MVC pattern, popular frameworks such as Laravel, and Testing. Definitely recommended to read for those who want to understand a concept, not cookbook style.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela