Wiki

Clone wiki

SiSA / Use SiSa In Your Project

How To Use SiSa In Your Project

SiSa is published at Composer, NPM and Bower. For details how to use it with these package managers have a look at the chapters below.

Use With Composer

PHP developers should know the package manager Composer. If not you should read about and install it. You can now create your composer.json by the following command

composer init

and follow the steps in your terminal. Or you add the following lines to your existing composer.json:

{
    "require": {
        "rebel-l/sisa": "~1.7"
    }
}

Now update your compser packages by executing

composer update rebel-l/sisa

The next step is to create your Vagrantfile. The easiest way is to use the init command:

vagrant init --minimal Ubuntu14.04LTS https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1

The --minimal options avoids that the Vagrantfile is flooded with annotations. The first parameter is just a name of your vagrant box (you can also use your own existing Ubuntu box). The second parameter is the url where to download the vagrant box. you can skip this.

Now edit your Vagrantfile and add the following configuration for chef:

devbox.vm.provision "chef_solo" do |chef|
    chef.cookbooks_path = "./vendor/rebel-l/sisa/cookbooks"
    chef.roles_path = "./vendor/rebel-l/sisa/roles"
    chef.environments_path = "./vendor/rebel-l/sisa/environments"
    chef.data_bags_path = "./vendor/rebel-l/sisa/data_bags"
    chef.add_role "WebServer"
    chef.environment = "development"

    chef.json = {
        'projects' => [
            {
                'name'          => [your project name],
                'type'          => 'php-simple',
                'server_name'   => [your dns],
                'root'          => '/vagrant/public',
                'index'         => 'index.php'
            }
        ]
    }
end

The data in the [] must be replace with your data. Now the whole Vagrantfile should look something like this:

Vagrant.configure(2) do |config|
    config.vm.box = "Ubuntu14.04LTS"
    config.vm.box_url = "https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1"

    config.vm.define "YourDevBoxName" do |devbox|
        devbox.vm.provision "chef_solo" do |chef|
            chef.cookbooks_path = "./vendor/rebel-l/sisa/cookbooks"
            chef.roles_path = "./vendor/rebel-l/sisa/roles"
            chef.environments_path = "./vendor/rebel-l/sisa/environments"
            chef.data_bags_path = "./vendor/rebel-l/sisa/data_bags"
            chef.add_role "WebServer"
            chef.environment = "development"

            chef.json = {
                'projects' => [
                    {
                        'name'          => [your project name],
                        'type'          => 'php-simple',
                        'server_name'   => [your dns],
                        'root'          => '/vagrant/public',
                        'index'         => 'index.php'
                    }
                ]
            }
        end
    end
end

Now you can run your virtual machine:

vagrant up

Now you can work with your machine. Have fun.

Use With NPM

NPM is a package manager for NodeJS which is similar to PHPs Composer. You can create a package.json by the following command

npm init

and follow the steps in your terminal. Or you add the following lines to your existing package.json:

{
  "dependencies": {
    "rebel-l-sisa": "~1.7"
  }
}

Now install the package by executing the following command:

npm install

The next step is to create your Vagrantfile. The easiest way is to use the init command:

vagrant init --minimal Ubuntu14.04LTS https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1

The --minimal options avoids that the Vagrantfile is flooded with annotations. The first parameter is just a name of your vagrant box (you can also use your own existing Ubuntu box). The second parameter is the url where to download the vagrant box. you can skip this.

Now edit your Vagrantfile and add the following configuration for chef:

devbox.vm.provision "chef_solo" do |chef|
    chef.cookbooks_path = "./node_modules/rebel-l-sisa/cookbooks"
    chef.roles_path = "./node_modules/rebel-l-sisa/roles"
    chef.environments_path = "./node_modules/rebel-l-sisa/environments"
    chef.data_bags_path = "./node_modules/rebel-l-sisa/data_bags"
    chef.add_role "Default"
    chef.environment = "development"
    chef.add_recipe "NodeJs"

    chef.json = {
        'System' => {
            'Iptables' => {
                'TCP'   => {
                    'Ports' => [8080]
                }
            }
        }
    }
end

The port 8080 is the port where your application is running. If it is a different one feel free to change it. Now the whole Vagrantfile should look something like this:

Vagrant.configure(2) do |config|
    config.vm.box = "Ubuntu14.04LTS"
    config.vm.box_url = "https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1"

    config.vm.define "YourDevBoxName" do |devbox|
        devbox.vm.provision "chef_solo" do |chef|
            chef.cookbooks_path = "./node_modules/rebel-l-sisa/cookbooks"
            chef.roles_path = "./node_modules/rebel-l-sisa/roles"
            chef.environments_path = "./node_modules/rebel-l-sisa/environments"
            chef.data_bags_path = "./node_modules/rebel-l-sisa/data_bags"
            chef.add_role "Default"
            chef.environment = "development"
            chef.add_recipe "NodeJs"

            chef.json = {
                'System' => {
                    'Iptables' => {
                        'TCP'   => {
                            'Ports' => [8080]
                        }
                    }
                }
            }
        end
    end
end

Now you can run your virtual machine:

vagrant up

Now you can work with your machine. Have fun.

Use With Bower

Bower is an alternative package manager mainly used for frontend javascript. But it uses NodeJS as NPM does it. You can create a bower.json by the following command

bower init

and follow the steps in your terminal. Or you add the following lines to your existing bower.json:

{
    "dependencies": {
      "rebel-l-sisa": "~1.5.0"
    }
}

Now install the package by executing the following command:

bower install

The next step is to create your Vagrantfile. The easiest way is to use the init command:

vagrant init --minimal Ubuntu14.04LTS https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1

The --minimal options avoids that the Vagrantfile is flooded with annotations. The first parameter is just a name of your vagrant box (you can also use your own existing Ubuntu box). The second parameter is the url where to download the vagrant box. you can skip this.

Now edit your Vagrantfile and add the following configuration for chef:

devbox.vm.provision "chef_solo" do |chef|
    chef.cookbooks_path = "./bower_components/rebel-l-sisa/cookbooks"
    chef.roles_path = "./bower_components/rebel-l-sisa/roles"
    chef.environments_path = "./bower_components/rebel-l-sisa/environments"
    chef.data_bags_path = "./bower_components/rebel-l-sisa/data_bags"
    chef.add_role "Default"
    chef.environment = "development"
    chef.add_recipe "NodeJs"

    chef.json = {
        'Iptables' => {
            'Whitelist' => {
                'Ports' => [8080]
            }
        }
    }
end

The port 8080 is the port where your application is running. If it is a different one feel free to change it. Now the whole Vagrantfile should look something like this:

Vagrant.configure(2) do |config|
    config.vm.box = "Ubuntu14.04LTS"
    config.vm.box_url = "https://www.dropbox.com/s/gzbxpgjih67uu2t/ubuntu1404lts5018.box?dl=1"

    config.vm.define "YourDevBoxName" do |devbox|
        devbox.vm.provision "chef_solo" do |chef|
            chef.cookbooks_path = "./bower_components/rebel-l-sisa/cookbooks"
            chef.roles_path = "./bower_components/rebel-l-sisa/roles"
            chef.environments_path = "./bower_components/rebel-l-sisa/environments"
            chef.data_bags_path = "./bower_components/rebel-l-sisa/data_bags"
            chef.add_role "Default"
            chef.environment = "development"
            chef.add_recipe "NodeJs"

            chef.json = {
                'Iptables' => {
                    'Whitelist' => {
                        'Ports' => [80]
                    }
                }
            }
        end
    end
end

Now you can run your virtual machine:

vagrant up

Now you can work with your machine. Have fun.

Updated