Laravel 5.4 dropped support to switch out the default blade tags… Use Twig instead, pretty much the same anyway.

Dropping out the default blade syntax used to be as simple as dropping this into the AppServiceProvider->boot function:

But out of the blue, they dropped the setContentTags support..

As a result the migration 5.3->5.4 was either change out all the js tpl syntax for alternatives, or preface every single non-blade with @{{ somethingFromAng }}.

As Twig is basically the same syntax as blade and uses pretty much the same inheritance system, instead of changing any template code, the easier option is to drop blade in favour of twig. Twig is a more flexible tpl language IMHO opinion anyway so win win ūüôā

EZPublish migrating content types.

Use this: https://github.com/kaliop-uk/ezmigrationbundle

The basic idea is to write yaml files that act as migration files. If you are familiar with the db migrations from the Laravel 4+ framework you will already have a feel for it.

Each migration is only run once and stored in the database.

First create the migration file after installing with:

Change the content of the YML to something like this simple content type.

Run the migration on the server:

Getting EZPlatform to display google maps in the admin

As of writing ezplatform still cannot handle google maps api keys.

This is a hack till the release is out there to use ( https://jira.ez.no/browse/EZP-26068 )

First up grab yourself a key

  1. https://console.developers.google.com click on the library section in the side nav.
  2. In the top nav should now be a button for enable, you will need to then follow the on screen instruction to get an api key.
  3. Then do the same for Google Maps Geocoding API. This will enable the address lookup for the content type.

Next add your key to the following files where they ref. the google url:
Definitely needed:
ezplatform/vendor/ezsystems/platform-ui-bundle/Resources/public/js/services/ez-googlemapapiloader.js

Might as well whilst you are there:
ezplatform/vendor/ezsystems/platform-ui-bundle/Tests/js/services/assets/ez-googlemapapiloader-tests.js
ezplatform/web/bundles/ezplatformui/js/services/ez-googlemapapiloader.js

That should be it, clear ‘dem cache and¬†you should be good to go. Just remember to repeat this on every environment and after a composer update… although hopefully this should be fixed soon!

 

 

File mounting from one server to another via ssh

Mounting the shared folders with ssh

NB: It is not possible for this to purely be done as root. Doing so will allow the command to added to the fstab but will also prevent apache from read and write access to the shared folder.

HTTP SERVER

  1. Create a home directory for www-data as /home/www-data and chown to www-data.
  2. Edit the /etc/passwd file and change the line for apache to use the new folder as its home directory and bin bash as the login (see how this is done for another user for an example, eg cloud).
  3. From root, su to ww-data
  4. run ssh-keygen
  5. create an ssh config for apache and add:
    Host file-share-server
       # this host name is a shortcut set in the hosts file
       HostName serverAliasName
       Port 22
       User shareuser
  6. Add the ip of the database server to the etc/hosts file and an alias ofserverAliasName
  7. Back as root, install: ¬†“apt-get install sshfs”
  8. Grab the root ssh public key: ¬† ‘cat /home/www-data/.ssh/id_rsa.pub’

SOURCE SERVER

  1. If this is the first share setup via sshfs… you should edit the /etc/ssh/sshd_config file and add the AllowUsers directive. Allow, shareuser root… and anyone else who should have ssh access. Save and restart ssh.
  2. The folder to be shared, chown it to a user and group of shareuser
  3. Logged in as root su as shareuser
  4. If there are not already any ssh keys for shareuser, create them with ssh-keygen.. again don’t add a pass phrase.
  5. Now make an authorized keys file:   nano ~/.ssh/authorized_keys
  6. Add a note for which server’s root key you are adding ( eg: ¬†# prod1 www-data ), paste the key in a new line and save.

HTTP SERVER INITIAL MOUNT

  1. From root: su www-data
  2. Try ssh to the shared folder server: ¬†“ssh file-share-server”
  3. You should see “do you trust…” enter y and proceed.
  4. If not logged in there there was a permissions issue or key issue. (.ssh should be 600 with its contents being 0700)
  5. First edit the /etc/fuse.conf file.. uncomment the line with user_allow_other directive

  6.  
  7. That should now have mounted over ssh the share.

HTTP SERVER Configure the auto-mounting of this drive for apache (not possible with fstab as sshfs needs to be run as apache)

  1. Create a bash script in the roots home directory called “mount_cdc_shared_drive.sh”:

     

    Make it executable

  2. Check it runs and works. Remove the mount first and then run the bash script to be 100% sure.
  3. Add a statup job in /etc/init… nano mount_file_shared_drive

That should be it. The bash script should mount the drive automatically via sshfs on system startup.

Un-mounting the folder is just the same as the usual commands: