How to Use the PHP Starter Site Template in WebMatrix

WebMatrix templates get you started with creating a website. The PHP Starter Site template lets you start with a website with a professionally designed layout. It also includes a simple login system and allows administrators to manage the pages on the site.

This article walks you through the following:

  • How to create a site from the WebMatrix Starter Site template for PHP.
  • An overview of the site contents.
  • Suggestions for tasks to get started with the site created by the template.

Create a site from the Starter Site template

1. In WebMatrix, select File → New → Site from Template Gallery.

2. On the left of the Site from Template window, select the PHP category, and then select Starter Site.

3. In the Site Name box, use the default name or enter a new name, and then click Next.

clip_image002

4. The template generates a website that uses MySQL database. The install wizard will ask you to create a root password for the new database (if MySQL is not yet installed) or enter existing password if MySQL is already installed.

clip_image004

5. If PHP and MySQL are not already installed on your computer, WebMatrix will walk you through the steps to install them. It will show you the End User License Agreement for MySQL and PHP. Click I Accept to proceed.

clip_image006

That’s it! You can now start customizing your website.

Site Contents

After the site has been created from the Starter Site template, the site opens in the WebMatrix Site workspace. This workspace displays the setup information of your website such as its URL and path to the local folder directory. On the site dashboard, you’ll also find resource links—a URL to the php.net website, where you can find useful information on PHP development, and links to WebMatrix forums where you can report product issues or suggest new features.

The lower left corner shows you the four workspaces available in WebMatrix. Click on Files to go to the Files workspace where you can view and edit your code.

clip_image008

In the left pane of the Files workspace, the directory structure of your new site contains the following folders and files:

Functions folder

Contains a database.php file that ensures that default tables and data are installed in the MySQL database for the website.

Images folder

Contains images for the website.

Includes folder

Defines common code blocks used throughout the site. closeDB.php and connectDB.php handle database connections. session.php is responsible for accessing and maintaining user login sessions. The files header.php and footer.php comprise a layout template for the pages on the website. The file simplecms-config.php contains database connection information as well as the default admin username and password for the site.

Styles folder

Contains a cascading style sheet (CSS) file named Site.css. This defines the style and appearance of the elements and text in the web pages.

Index.php and other files

Index.php is the default home page of the site.

The following pages each perform the management task indicated by their filenames:

addpages.php, deletepage.php, editpage.php, page.php, selectpagetoedit.php.

The remaining pages handle user login and registration.

Robots.txt tells search engines and web spiders which files and folders they can index when crawling your site.

Favicon.ico is the website’s icon

Getting Started Tasks

1. To launch your website on your local computer, in the top left corner of WebMatrix, click Run. The default home page appears:

clip_image010

2. In the top right corner of the page, click Login. Log on as an administrator by using the admin credentials you that entered for the site when you installed the template. (These credentials were also stored in the config file in the Includes directory).

In the navigation area at the top, you can select Add to add a page to the website, or Edit or Delete to modify or remove an existing page. Users of the site will see a Register button that they can use to create non-administrative accounts for themselves.

By default, registered users who are not administrators have the same privileges as non-registered users. They can only view pages; they cannot add, modify, or delete them. If you want, you can add code to create special privileges available only to users who are registered.

You can discuss this article using the adjacent Facebook talkback.

For technical questions please visit our discussion forums, where we have a vibrant community of developers like you, as well as Microsoft engineers who are ready to answer your questions!