Thursday, September 19, 2013

Mac OSX Terminal: How to delete all files and folders in a folder

Simply type:
>rm -rfv *

... and press enter! Easy!

Wednesday, September 18, 2013

Widgets in silverstripe

A few pointers if you are also struggling with it.

  1. If the widgets are not clickable
    1. You probably haven't installed the widgets module correct. Try installing via composer
  2. If page is running out and returning nothing.
    1. Are you using a widget that has a Content field? In that case try renaming it to someting unique.
  3. Want to have multiple widget areas?
    1. Add as many as you like, but do add a tab for each like this:
      $fields->addFieldToTab("Root.MyWidgetArea", new WidgetAreaEditor("MyWidgetArea"));

When using Composer to install something, how do I know what version to use?

When installing stuff with Composer it usually asks what version you wanna use.

You can see the different versions available if you locate the package on https://packagist.org.

For instance, the widgets package.
https://packagist.org/packages/silverstripe/widgets

It has 2 versions:


  1. dev-master (almost always available)
  2. 0.1.x-dev (in this case a SS 3.0 compatible version)

silverstripe CMS 3.1.0 and composer

This was new to me, so I actually struggled quite a bit with this. Now I think I have it more or less under control.

Installing composer

Open up a Terminal window and fire this command:

curl -sS https://getcomposer.org/installer | php

You might need to apply -d detect_unicode=Off after the php like this:

curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off

That if you don't wanna change your php.ini

Installing Git

Go to: http://git-scm.com/download/mac and download Git. Click it and click the pkg-file. Close your Terminal (cmd + q) and start it again. Write git and see that it works.

Using composer

Your silverstripe project has a composer.json file in the root. It might be empty.
I found this and pasted it into the file:

{
    "name": "silverstripe/installer",
    "description": "The SilverStripe Framework Installer",
    "require": {
        "php": ">=5.3.2",
        "silverstripe/cms": "*",
        "silverstripe/framework": "*",
        "silverstripe-themes/simple": "*"
    },
    "require-dev": {
        "silverstripe/compass": "*",
        "silverstripe/docsviewer": "*"
    },
    "minimum-stability": "dev"
}

In order to install, say silverstripe widgets I used this command:

> composer require silverstripe/widgets

You will be asked for a version, I chose dev-master (being the latest and greatest).
I actually had a hard time working out how the versioning works. But dev-master worked for me.

Wednesday, September 4, 2013

MAMP 5.2+5.4 and PHP 5.5 from Liip

Some things require different versions of PHP. Thats why I have to run a number of different versions.

Install PHP 5.5 with this command:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5

From the site: http://php-osx.liip.ch/

Then you have to change some settings in the httpd file. (/private/etc/apache2/httpd.conf). You might need to enable the php5 module.

Start your apache server with the command: sudo apachectl start
... and stop it again with sudp apachectl stop.

Local mysql (not the MAMP one) can be started and stopped with:

/usr/local/mysql/support-files/mysql.server start    (and stop for stopping)

If MAMP services wont start you can try to run the sh scripts in /Applications/MAMP/bin/
Run sh with the command:
> sh stopMysql.sh

This will tell if it worked and also the location of the log file to look for any errors.