Sage Installation – Update for version 9

  • Update: 4-12-2018

For older versions of Sage see this post

https://github.com/roots/sage

https://roots.io/sage/docs

Changes in Sage 9

  • Laravel’s Blade as a templating engine.
    Learn about Blade. Check out the templates directory.

    You can opt-out of Blade templates by replacing them with regular PHP ones (you could copy over the templates from Sage 8 if you really wanted to).

  • Replaced gulp and Bower with Webpack and npm.
    Bower is dead and all packages should be available on npm.

    Webpack is responsible for:

    • Compiling assets
      • Sass to css with ccsnano
      • ES6 to JavaScript that can be run in today’s browsers with buble
    • Optimizing images with optipng, gifsicle, pngquant, and svgo
  • ES6 for Javascript
    Great resource for learning about ES6: Wes Bos’ ES6 for Everyone
    Convert existing JS to ES6 with Lebab
  • Bootstrap 4
    It’s still in alpha, but there’s so many improvements over Bootstrap 3.
  • PSR-2 coding standards.
    Roots projects switched to PSR-2 last year. Previously we had used a modified PSR-2 ruleset, but we stopped caring about 2-spaces in our PHP files and fully adopted PSR-2.
  • Restructured theme files.
    All theme templates are finally out of the theme root! Our implementation is a little hacky because a 7 year old WordPress Trac ticket still hasn’t landed, but we believe our implementation is the best we can do at this time.
  • Introduced Yarn.
    Yarn is a drop in npm client replacement. With Yarn, the installation of Node dependencies is quicker & the node_modules directory is smaller.

Theme Installation

  1. Make sure all dependencies have been installed before moving on:
    PHP >= 5.6.4 7.1.3 (with php-mbstring enabled)
    – Add the wamp php (at least 7.1.3) to Windows PATH (and no other php in the path).
    – make sure extension=php_mbstring.dll is enabled in the php.ini of the php version you are using (default= enabled)
    Composer (Dependency manager)
    Node.js >= 6.9.x
    – If necessary install Node (with npm). I used the Windows installer here (x64 version)
    Yarn
  2. From your WordPress themes directory, run the following composer command:
    composer create-project roots/sage your-theme-name dev-master

    During theme installation you will have the options to:

    – Update theme headers (theme name, description, author, etc.)
    – Select a CSS framework (Bootstrap, Foundation, none)
    – Add Font Awesome

    Update: Newest version of Sage9 (9.0.5 at the time of writing) gives the following error: 

    TTY mode is not supported on Windows platform

    Solution: run this from the theme directory

    ./vendor/bin/sage meta        # or edit style.css directly
    ./vendor/bin/sage config      # or edit resources/assets/config.json
    ./vendor/bin/sage preset      # Install css framework
  3. Navigate to the theme directory then run yarn, and yarn build (to refresh files):

    yarn && yarn build

    You now have all the necessary dependencies to run the build process.

    About dependencies:
    If you open package.json you’ll see both devDependencies and dependencies that Sage uses. devDependencies are used by the build process, whereas dependencies are packages that are used in the front-end theme assets.

    dependencies includes the front-end options you selected during install, such as Bootstrap and Font Awesome

    "dependencies": {
      "bootstrap": "^4.0.0-beta",
      "font-awesome": "~4.7",
      "jquery": "1.12.4 - 3",
      "popper.js": "~1.11"
    }

————————–

Install WordPress and activate plugins

Optionally import test data with WP Test. See here

Warning when activating i-themes Security:

When activiating this plugin, it will write to your wp-config.php.
This causes an error with the Bedrock config setup and make you website/admin unaccesible.
Solution:
– activate i-themes
– edit wp-config.php -> remove file permissions added by i-themes (we use config/application.php for that)
– WP admin should be accesible again
– Go to i-themes settings-> WordPress Tweaks -> File Editor -> uncheck the box

Read More

WordPress with GIT, WP-Skeleton and Roots 101

Goals: – Keep a local WordPress  installation under version control (but ignore WordPress core files) – Use WP-Skeleton (wordpress core as submodule in separated folder, content and config files in root) – Use the starter theme Roots 101 – Deploy to a staging and production server (depending on the current Git branch?) – Keep uploads out of version control, sync them separately – Use a good DB migration strategy – If possible: automate repetitive tasks Read More

Setup SSH

Follow the steps in this post on bitbucket.org

https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

There is also a script in there to configure your bash shell to automatically start the agent when launch the shell.

Local: go to .ssh directory

ssh-keygen

Name your key and give a password

Add the key to the ssh-agent:

ssh-add ~/.ssh/id_rsa # or whatever the name of the key is

tip: create an alias sshaddxx

How to add the public key to bitbucket:

  • From Bitbucket, choose Personal settings from your avatar in the lower left.

  • https://bitbucket.org/account/settings/
  • Click SSH keys.
    If you’ve already added keys, you’ll see them on this page.

  • In your terminal window, copy the contents of your public key file. If you renamed the key, replace id_rsa.pub with the public key file name.

    On Linux, you can cat the contents:

    $ cat ~/.ssh/id_rsa.pub

  • Select and copy the key output in the clipboard.
    If you have problems with copy and paste, you can open the file directly with Notepad. Select the contents of the file (just avoid selecting the end-of-file characters).

  • From Bitbucket, click Add key.

  • Enter a Label for your new key, for example, Default public key.

  • Paste the copied public key into the SSH Key field.
    You may see an email address on the last line when you paste. It doesn’t matter whether or not you include the email address in the Key.

  • Click Save.
    Bitbucket sends you an email to confirm the addition of the key.

  • Return to the terminal window and verify your configuration and username by entering the following command:

    $ ssh -T git@bitbucket.org

    The command message tells you which of your Bitbucket accounts can log in with that key.

  1. conq: logged in as emmap1.
    You can use git or hg to connect to Bitbucket. Shell access is disabled.

    If you get an error message with Permission denied (publickey), check the Troubleshoot SSH issues page for help.

Now that you’ve got an SSH key set up, use the SSH URL the next time you clone a repository. If you already have a repository that you cloned over HTTPS, change the remote URL for your repository to use its SSH URL.

Edit an SSH key

After you add a key, you can edit the key’s Label but not the key itself. To change the key’s contents, you need to delete and re-add the key.

How to add public keys to the server: Read More

A web-focused Git workflow

  • Follow the steps in this post from Joe Maller
    http://joemaller.com/990/a-web-focused-git-workflow/Some key advantages of this setup:
    – Pushing remote changes automatically updates the live site
    – Server-based site edits won’t break history
    – Simple, no special commit rules or requirements
    – Works with existing sites, no need to redeploy or move files
  • Don’t forget to make the hooks executable (chmod +x) !!
  • A similar approach (but without a hook to pull changes on live website, I believe) is found here: http://mattbanks.me/wordpress-deployments-with-git/