latest version

Wordpress And Boilerplates Installation

Video Walkthrough

If you like, you can watch a video walkthrough below covering steps of this chapter setup.

There is also another video covering “Project setup” and basic git workflow.

Download Tools

Here are the links to necessary tools. Please start downloading them and in the meantime go ahead and proceed with next instructions.

Everyone:

  • PHPStorm as preferred IDE: PHPStorm EAP
  • Git for GitLab access: Git
  • PHP (for Composer): PHP
  • Composer for getting the framework code: Composer

Backend tools:

Frontend tools:

Setup Hosts

This step is optional, however sometimes it helps to keep the connection alive.

  1. Open file C:\Windows\System32\drivers\etc\hosts in administrator mode

  2. Add the following lines at the end (where CT_SERVER_NUMBER is you CT number)

    10.0.0.111 pinky.createit
    10.1.0.101 CT_SERVER_NUMBER.phinky.createit
    
  3. The addresses may change, please ask your project manager for the actual addresses.

Setup Pinky (Poland) or PHinky (Philippines)

First, mount your server space as a local drive.

Basically, what you need to do is:

  1. Go to My computer
  2. Click Map network drive button
  3. Select drive letter (we’ll use V in the examples)
  4. Enter location: \\pinky.createit\www\CT_SERVER_NUMBER\ or CT_SERVER_NUMBER.phinky.createit\wwww\CT_SERVER_NUMBER (replace CT_SERVER_NUMBER with your information, eg. ct11)
  5. Done. Check if you can browse your Pinky or PHinky.

More detailed instruction can be found here

WordPress Installation

WordPress

  1. Download the latest WordPress
  2. Unpack the contents to V:\wp\
  3. You should have the following structure: V:\wp\wp-config-sample.php
  4. In your browser, open: http://CT_SERVER_NUMBER.pinky.createit
  5. WordPress Installation will appear
  6. Set database name: wp_CT_SERVER_NUMBER, eg. wp_ct11
  7. Set database username: wp_CT_SERVER_NUMBER, eg. wp_ct11
  8. Set database password: ct
  9. Set database host: localhost
  10. Set table prefix: wp_
  11. Click: Submit
  12. Choose English language
  13. Set your CT_SERVER_NUMBER as a site title
  14. Set username: createit
  15. Set password: createit
  16. Check: Confirm use of weak password
  17. Set email: Your CT domain e-mail address
  18. Check: Discourage search engines from indexing this site
  19. Click: Install WordPress
  20. Click: Log in (twice)
  21. Now, You should be logged in to WordPress wp-admin panel

Multisite

Multisite will allow you to have multiple themes installations at one place.

  1. In notepad open V:\wp\wp-config.php
  2. Above the line /* That's all, stop editing! Happy blogging. */ add text: define( 'WP_ALLOW_MULTISITE', true );
  3. In a browser, open: http://CT_SERVER_NUMBER.pinky.createit/wp-admin/
  4. Enter menu: Tools -> Network setup
  5. Select: Sub-directories
  6. Click: Install
  7. Follow the on screen instructions
  8. Now, You should have access to network settings on top of wp-admin panel

Got stuck? Here’s a Codex tutorial on how to Create a Network

Install PHP

  1. Download the current stable PHP version at PHP Windows

  2. Unzip contents to C:\php\

  3. Rename file C:\php\php.ini-development to C:\php\php.ini

  4. Open C:\php\php.ini and uncomment openssl extension, ie. change line

    ;extension=php_openssl.dll
    

    to

    extension=php_openssl.dll
    
  5. That’s all

Install Composer

  1. Just in case, install Visual C++ Redist
  2. Download Composer
  3. Run the installer with default options

Install Git

  1. Download Git
  2. Run the installer with default options

Setup PHPStorm

  1. Download PHPStorm EAP . It is an EAP, so you will need to download new version and reinstall it every 30 days.

  2. Run the installer

  3. Check to install: JRE by JetBrains

  4. Install

  5. Run and open File -> Settings -> Version Control -> Git and enter path to installed git.exe

  6. Open File -> Settings -> Build & Execution & Deployment -> Deployment and enter settings as follows changing ct11 to your CT Server Number

    ../../_images/deployment-settings.png ../../_images/deployment-settings-mapping.png ../../_images/deployment-settings-auto.png
  7. Make sure you have set pinky as default deployment (in servers list, right click on your pinky and check set as default)

  8. You can add Wordpress support yo your PHPStorm by adding path to folder with fresh Wordpress Installation.

    ../../_images/wordpressSuport-settings.png ../../_images/wordpressSuport-settings.png
  9. Your PHPStorm is configured

Boilerplate Checkout

  1. Create a directory C:\work\boilerplate

  2. Copy contents of V:\wp (including hidden files) to C:\work\boilerplate

  3. Run PHPStorm and click: Open…, and select C:\work\boilerplate

  4. In PHPStorm menu click: File -> Settings -> Languages & Frameworks -> PHP -> Frameworks and check: Enable WordPress integration and type path to WP files: C:\work\boilerplate

  5. In PHPStorm menu click: VCS -> Checkout from version control -> Git

  6. Enter Git repository URL: Theme boilerplate

  7. Enter parent directory: C:\work\boilerplate\wp-content\themes

  8. Enter directory name: theme-boilerplate

  9. Click: Clone and enter credentials

  10. After a while you should have C:\work\boilerplate\wp-content\themes\theme-boilerplate directory content cloned from Git

  11. Repeat checkout with Theme Plugin boilerplate and Theme Demo Plugin boilerplate to C:\work\boilerplate\wp-content\plugins directory

  12. For Theme Plugin and Theme Demo Plugin you also need to composer update the framework.
    1. In PHPStorm, press Alt+F12 to open the terminal

    2. Go to Theme Plugin directory (eg. type cd \, press enter, type cd work\boilerplate\wp-content\plugins\theme-plugin-boilerplate, press enter)

    3. Type composer update and press enter

    4. Here’s a screenshot of PHPStorm Terminal:

      ../../_images/composer-install.png
    5. Unyson and Bumblebee frameworks should now be present in vendor directory.

    6. Repeat these steps for Theme Demo Plugin

Deployment

Let’s try to send those files to server.

  1. In Project view, right click on C:\work\boilerplate\wp-content\themes\theme-boilerplate directory and click: Upload to pinky
  2. Go to file explorer and check if files were sent to the server. If not, check your Deployment settings
  3. Go to http://CT_SERVER_NUMBER.pinky.createit/wp-admin and select on the top: My Sites -> Network Admin -> Themes
  4. Theme boilerplate should be visible on the list of themes. Network activate it.
  5. Now, you can activate the theme in site wp-admin.

Setup new project

You can wath a video covering this chapter

When you have your project assigned, follow these steps.

  1. Create a new folder, eg. c:\work\projectname (replace projectname with the actual project name)

  2. Copy contents of c:\work\boilerplate to c:\work\projectname

  3. Optionally, delete contents of c:\work\projectname\wp-content\themes and c:\work\projectname\wp-content\plugins

  4. In PHPStorm choose File -> Open and select c:\work\projectname

  5. Once opened, checkout your project files from Git (most likely, they will be empty)

    1. Checkout project theme to c:\work\projectname\wp-content\themes ( so in result you have c:\work\projectname\wp-content\themes\projectname\ ),
    2. Checkout project plugin to c:\work\projectname\wp-content\plugins ( so in result you have c:\work\projectname\wp-content\plugins\projectname-plugin\ )
    3. Checkout project demo plugin to c:\work\projectname\wp-content\plugins ( so in result you have c:\work\projectname\wp-content\plugins\projectname-demo-plugin\ )
  6. Once checked out, in file explorer, copy boilerplate files to your project folders

    1. Copy theme-boilerplate contents to c:\work\projectname\wp-content\themes\projectname\theme (create directory theme), so in result you have c:\work\projectname\wp-content\themes\projectname\theme\style.css
    2. Copy theme-plugin-boilerplate contents to c:\work\projectname\wp-content\plugins\projectname-plugin
    3. Copy theme-demo-plugin-boilerplate contents to c:\work\projectname\wp-content\plugins\projectname-demo-plugin

Commit changes

  1. In PHPStorm open c:\work\projectname
  2. In PHPStorm project tree view, right click on c:\work\projectname\wp-content\themes\projectname folder and select git -> add
  3. In PHPStorm project tree view, right click on c:\work\projectname\wp-content\plugins\projectname-plugin folder and select git -> add
  4. Press Ctrl+K, select all files you wish to send to git, then press ‘commit & push’. Alternatively, you can right click on a folder and select git -> push.

Additional backend settings

wp-config.php

Add below lines to your wp-config.php content (anywhere above wp-settings.php load line):

# set this for easy plugin installation
define("FS_METHOD",'direct');

# set error show
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

.htaccess (optional)

You may take advantage of xdebugger by setting .htaccess something like this:

Note

This may have a little negative effect on site performance

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

# general errors
php_flag display_startup_errors on
php_flag display_errors on
php_flag log_errors on
php_value error_log  /var/www/YOUR-PATH/logs/PHP_errors.log
php_value error_reporting -1
php_value short_open_tag false

# xdebug dump
php_value xdebug.var_display_max_depth 20
php_value xdebug.var_display_max_children 256
php_value xdebug.var_display_max_data -1
php_value xdebug.max_nesting_level 5000
php_value xdebug.show_local_vars 1
php_value xdebug.collect_params 1
# php_value xdebug.collect_assignments 1
# php_value xdebug.collect_includes 1
# php_value xdebug.collect_return 1

# xdebug debugger
php_value xdebug.remote_connect_back 1

# xdebug profiler
php_value xdebug.profiler_enable 0
php_value xdebug.profiler_enable_trigger 1
php_value xdebug.profiler_enable_trigger_value PHPSTORM
php_value xdebug.profiler_output_dir /var/www/YOUR-PATH/logs/profiler
php_value xdebug.profiler_output_name callgrind.%H%R.callgrind

# xdebug trace
php_value xdebug.auto_trace 0
php_value xdebug.trace_enable_trigger 1
php_value xdebug.trace_enable_trigger_value PHPSTORM
php_value xdebug.trace_output_dir /var/www/YOUR-PATH/logs/trace
php_value xdebug.trace_output_name trace_%H%R
php_value xdebug.trace_format 0

Database access

If you need database access, use one of the following tools:

Here is an Adminer basic setup. Adminer is a simple PHP tool.

  1. Download Adminer

  2. Place adminer-#####-mysql.php file in your server wordpress directory, eg. V:\ct11\wp\adminer.php

  3. Open the file in browser, eg. http://ct11.pinky.createit/adminer.php

  4. Enter db credentials (replace ct11 with your pinky number)

    ../../_images/adminer-credentials.png
  5. You should see all tables of your database:

    ../../_images/adminer-tables.png
  6. That’s it.

Tip

If you need to batch replace contents of your db, use SRDB2 PHP tool.