// komodo tool: Laravel Setup
// ==========================
// is_clean: true
// type: tutorial
// version: 1.1.5
// ==========================
# Sample content, edit, delete, do whatever you like
Description: Tutorial to quickly set up a Laravel project in Komodo.
Author: ActiveState
Version: 1.0
# Placement can be floating or docked
Placement: docked
Callouts:
    placesWidget:
        Element: "#placesViewbox"
        Message: This is the Places widget.
    projectCog:
        Element: "#placesSubpanelProjectsTools_SPV"
        Message: "This is the Project cog menu."
    menuButton:
        Element: "#unifiedMenuButton"
        Message: "This is the Menu button."
        Fail: "Enable the main toolbar using View > Toolbars > Show Toolbars"
    uniMenuButton:
        Element: "#unifiedMenuButton"
        Message: Access Komodo menus in the Unified Menu.
    toolboxWidget:
        Element: "#toolbox2viewbox"
        Message: "This is the Toolbox widget."
        Fail: "Open Toolbox using View > Tabs & Sidebars > Toolbox or Ctrl + Shift + L"
Steps:
    -
        Title: Before you begin
        Summary: >
            If you are new to the **Komodo IDE** you should complete the
            **Getting Started** tutorial before continuing.  It is located
            in the [toolbox][callout:toolboxWidget] in the Tutorials folder.
            It teaches the basics of using Komodo.

            This tutorial is based on the
            [Laravel installation documenation](https://laravel.com/docs),
            with specific instructions for configuring Komodo.

            In this tutorial you will learn how to:
            - Create a Komodo project
            - Install Laravel
            - Generate the Laravel project code
            - Create a custom Toolbox command to start the Laravel server

            ## Prerequisites

            - PHP
            - Composer

            #### PHP

            Instruction on installing PHP can be found here: http://php.net/manual/en/install.php

            ##### Configuring PHP

            **NOTE** If PHP is on your system PATH the Komodo configuration is completed automatically at startup.

             1. Open the Preferences dialog box:
                - Select <% if (require("sdk/system").platform == "darwin") { %>**Edit menu > <% } else { %> <i class="icon icon-bars"></i>&nbsp;**[Menu button][callout:uniMenuButton] > Edit <% } %>  Preferences > Languages**.
                - Press `Ctrl + ,` (or `Cmd + ,` on Mac OS X)
             1. Expand the **Languages** list in the sidebar, and select PHP.
             1. Click the **Browse** button next to the **Use this interpreter**
             field, select your PHP installation directory, and
             select the PHP interpreter binary file.
             
            #### Composer

            Instruction on installing PHP can be found here: https://getcomposer.org/doc/00-intro.md

            ##### Configuring Composer

            **NOTE** If Composer is on your system PATH the Komodo configuration is completed automatically at startup.

             1. Open the Preferences dialog box:
                - Select <% if (require("sdk/system").platform == "darwin") { %>**Edit menu > <% } else { %> <i class="icon icon-bars"></i>&nbsp;**[Menu button][callout:uniMenuButton] > Edit <% } %>  Preferences > Languages**.
                - Press `Ctrl + ,` (or `Cmd + ,` on Mac OS X)
             1. Expand the **Languages** list in the sidebar, and select PHP.
             1. Click the **Browse** button next to the **Composer Location**
             field, find and select your Composer installation binary.
             1. Click **Ok** or **Apply** then **Ok**.

        #Validate: validPageOne -> isPHPFound

    -
        Title: Creating a Komodo project
        Summary: >
            Your first task is to create a Komodo project that provides the context for the
            setup commands in this tutorial. All of these steps are completed in Komodo..
        Task: >
            1. Select <% if (require("sdk/system").platform == "darwin") { %>
            **Project menu >
            <% } else { %>
            <i class="icon icon-bars"></i>&nbsp;**[Menu button][callout:uniMenuButton] > Project >
            <% } %>
            New Project**.
            1. Enter a project and location for your project.
            1. Select *PHP* for the language and *Laravel* as the Framework.
            1. Click **Next**.
            1. In the *Run Command* field enter `composer require "laravel/installer"`.
            1. Click **Next**.
            1. When the command finishes click **Open Project**.

        Tips:
            - You can specify a custom **Project Base URL** in the **Project Preferences** dialog box.  Right click your project and select **Project Preferences** and then enter the custom URL in the **Project Base Directory** text box.
            - Komodo uses your system path to find installed tools.  You can also manually configure the location at the Global, Project, or File level preferences.  Komodo prioritizes preferences in the following hierarchy, File > Project > Global.
            - <% if (require("sdk/system").platform == "winnt") { %>Use `where [exectuableName]` in **Commando** to see what Komodo will find on your path.  Example `where XXXXXXX`<% } else { %>Use `which [exectuableName]` in **Commando** to see what Komodo will find on your path.  Example `which XXXXXXX`<% } %>

    -
        Title: Configuring Laravel
        Summary: >
            You need to complete the following steps to install and configure Laravel.
             - Install Laravel
             - Create your Laravel project
        Task: >
            1. Open Komodo Preferences, *Ctrl(Cmd) + ,* > Environment.
            1. Double click the `PATH` variable to move it to the *User environment Variables*.
            1. Select the `PATH` variable in the *User environment Variables* section then click **Edit**.
            1. Add the absolute path to `vendor/bin` folder in your project and click **Ok**
            1. Click **Ok** again to save and close the prefs dialog.
            1. Press `Ctrl + Shift + O` (or `Cmd + Shift + O` on Mac OS X)
            to open Go to Anything.
            1. Select Shell scope.
            1. Enter `laravel new blog`.  This will take a few minutes to complete.  You should see the following output when it's done:
            ```
            Application ready! Build something amazing.
            ```

        Tips:
            - The output of commands in Go to Anything (Commando) tell you which executable was used at the start of the output.  You should verify that the expected executable is displayed.
    -
        Title: Starting Laravel
        Summary: >
            You need to do the following steps to start Laravel:
            - Create a Toolbox Command to start the server.
            - Navigate to your site in your web browser.

            **NOTE**: You will be saving the tool in your Project toolbox.  Locate the red toolbox icon with the same name as your project at the bottom of the [Toolbox][callout:toolboxWidget].
        Task: >
            1. In the [Toolbox][callout:toolboxWidget] right click your project toolbox and select **Add > New Command**.
            1. Name the tool `Start Laravel Server`.
            1. Enter the following into the command field: `php artisan serve`.
            1. Click the **Advanced Options** tab.
            1. In the *Start In* field enter: `<% if (require("sdk/system").platform == "winnt") { %>
            %p\blog
            <% } else { %>
            %p/blog
            <% } %>`
            1. From the *Run in* drop down list select `New Console`.
            1. Click **OK**.
            1. Double click the Start Laravel toolbox command and
            it will open a terminal window with output that looks
            similar to the following:
            ```
            Laravel development server started: <http://127.0.0.1:8000>
            ```
            Open your web browser and navigate to the URL listed in the
            command output (e.g. http://localhost:8000) to see the site
            running.

            See the [Laravel Docs](https://laravel.com/docs/5.4) for more information.
// ==========================
// komodo meta: logic
// ==========================
// Sample content, edit, delete, do whatever you like
(function() {
    var {Cc, Ci} = require("chrome");
    var $ = require("ko/dom");
    var w = require("ko/windows").getMain();
    var ko = w.ko;
    
    this.start = function() {};
    this.preStep = function() {};
    this.step = function() {};
    this.preClose = function() {};
    this.close = function() {};

    this.focusPlaces = function()
    {
        ko.uilayout.ensureTabShown('placesViewbox', true);
        w.require("tutorials").logicCallout("placesWidget");
    };
    
}).apply(module.exports);