Wordpress Blog To PDF Plugin Demo

WordPress Blog to PDF Plugin can generate and export WordPress Blogs/Posts into a PDF Doc. WordPress Blog to PDF Plugin can also export the Blogs/Posts Revisions into the PDF.

Front Office Demo Back Office Demo

How to Install Yii on Windows or a Mac

What You’ll Be Creating

Want to know more about Yii? Read Introduction to the Yii Framework and follow our Yii Programming series.

In today’s tutorial, we’ll explain how to install Yii in a local development environment for both Windows and macOS. For the Windows guide, we’ll rely on WAMP Server, a Windows web development environment for Apache, PHP and Mac, and for the Mac guide, we’ll use its cousin, MAMP. Although Rod uses WAMP in today’s tutorial, there is also a Windows version of MAMP.

I’m writing the Mac portion of this guide, and my colleague Rod Ussing is writing the Windows side. I met Rod in high school in California at my second programming job, a very large hexadecimal number in years ago. He still uses Windows, but after eight years of working at Microsoft and tiring of rebooting the system to restart Outlook, I left for macOS.

Yii is an incredibly reliable, well-designed, high-performing framework for PHP, as Rails is for Ruby and similar to Laravel. If you’re wondering if you can build real-world applications in Yii, check out Meeting Planner and our Building Your Startup series.

  • How to Program With Yii2: Using the Advanced Application Template

  • Building Your Startup With PHP: Table of Contents

I love coding in Yii. Everything is faster and easier for me. And it’s relatively straightforward as far as frameworks go (that’s me throwing shade at Rails).

We’ll start with the basics of what’s unique installing Yii in macOS, and then move on to Windows. As what’s needed to complete the installation on each platform converges, we’ll describe the remaining instructions in a unified form for both platforms.

Yii Basic is the simplest form of Yii. You can build all kinds of applications with it, but it’s best for single tier, e.g. one customer facing side.

Here’s the directory structure of a Yii Basic application with just a set of directories for a single application:

The Yii 2 Advanced Project Template is best for developing complex Web applications with multiple tiers, such as front end, back end, and console, each of which is a separate Yii application. For example, administrative sites can run in the back end, and cron tasks can run in the console environment.

In contrast, here is the directory structure for a Yii Advanced application with multiple tiers:

Each tier is its own site, but they can easily share code and a common database if desired. I use this template in our startup series. Yii Advanced also provides built-in configuration support for different environments, making team development easier.

I’ve been coding in Yii on macOS for several years now. Sure, there are lots of different ways to run an Apache, MySQL, PHP environment on a Mac, but I prefer MAMP.

Install Yii on Windows or a Mac - MAMP Website Home Page

Basically, just visit the MAMP website and download the macOS package:

Install Yii on Windows or a Mac - MAMP Downloads Page

Once downloaded, you can drag the package to the Applications folder and double-click to launch MAMP. This will display a MAMP window:

Install Yii on Windows or a Mac - MAMP Window

Click Preferences to configure the ports you want to the server on (I use 8888 for Apache):

Install Yii on Windows or a Mac - MAMP Preferences Ports Configuration

Click Web Server to review or change the directory of your server. I use Apache locally:

Install Yii on Windows or a Mac - MAMP Preferences Web Server Configuration

Yii2 requires Composer, a popular dependency manager for PHP. If you don’t already have Composer installed, do the following:

Then, use Composer to install Yii2. The installation request requires that you use your own GitHub account credentials; sign up if you don’t have an account.

As Rod describes further below, installing Yii requires the composer asset plugin:

He recommends setting up an account with GitHub and configuring an access token. The reason for this is that during the installation of Yii, the number of requests may exceed the GitHub API rate limit, and Composer may stop and ask for your GitHub login credentials to obtain a GitHub API access token during the installation. 

When ready, you can install Yii. We’ll use Yii basic and install it in the ~/sites/hello directory:

Then, create a symlink for MAMP to your Sites app directory:

If you decide to install Yii Advanced, then it may help to activate and customize your virtual host file:

Below, I’ve configured frontend.dev and backend.dev to map to a Yii Advanced install in the ~/sites/yiiplus directory which has a symbolic link in /Applications/MAMP.

If you decide to use Yii Advanced, I encourage you to also check out my tutorial on this which offers more details.

Those are the platform-specific steps for macOS. Now let’s look at preparing for Yii on Windows. Later, we’ll return to finish the configurations with steps that work for both platforms. If you’re strictly a macOS user, jump ahead to the Completing the Yii Configuration section.

For Yii on Windows, we’re going to use WAMP. To begin, you’ll need to download and configure WAMP on your Windows computer. For this tutorial, we will be installing WAMP on your local computer (which the server will address as localhost). If you wish to install on a production Windows server, you will need to contact your provider for server details and follow the recommendations for installing and configuring WAMP Server or an alternative Apache, MySQL, PHP stack for that environment.

Install Yii on Windows or a Mac - WAMPSERVER Home Page

As the focus of this tutorial is on installing Yii, we suggest you consult one of the many excellent existing tutorials that cover installing WAMP; you will be surprised how easy it is. As it’s also a PHP application, the WordPress guide to installing WAMP is a good starting point.

Once we have installed and configured WAMP, we need to install Composer, which is a dependency manager and installer for PHP projects. This will enable us to get started with our Yii installation.

Although you can download Yii packages from GitHub, in this tutorial we’re using Composer to install it. If you’re not familiar with Composer, you can learn more in this tutorial.

First let’s go to GitHub to download and install the latest version of Composer-setup.exe, which at this time is v4.5.0.

Once the install is complete, it is a good idea to log off and log on again to be sure all files are updated [Jeff here: or buy a Mac].

You can check your install by opening the Command prompt and going to:

Enter the following command:

The version info for Composer should then be displayed, something like:

In order to manage your project assets in the Composer .json, without having to install NPM or Bower, you will need to make sure Composer has all the packages it needs by running the install command for the Composer Assets plugin.

Open the command prompt on Windows and navigate to where your PHP folder is located. On this install, PHP is located in the directory wamp64\bin\ and it is PHP version 7.0.10, so we type:

Then type the following command:

Keep in mind that software changes, so always be sure to check that you are working with the most current stable version. Be careful with betas because if you get too far out on the bleeding edge, things might start to break.

For the most current versions of Composer and Composer Asset Plugin:

Now, let’s configure WAMP for Yii. Change your directory to the WAMP installation\www for this installation:

In this directory, we will create a new directory named Yii Basic by typing:

This is where we are going to install Yii Basic. You could skip this step and install Yii straight into the www directory, but creating a clearly named directory avoids confusion, especially if you plan to install both Yii Basic and Yii advanced templates.

In the new yii-basic directory, we run the following command to install the Yii Basic Template:

We can verify Yii by navigating to the “Basic” folder in the directory you created:

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a demo store. Any orders placed through this store will not be honored or fulfilled.