I am working on OSX and have mjml globally installed via node.js. what i want to do is create a shell script thats called by PHP exec to enable MAMP PRO apache to use my local mjml installation.
that should be possible, right?
I can call mjml PARAMS at my terminal. it renders mjml to html.
which mjml => /usr/local/bin/mjml
my $PATH has /usr/local/bin
but i can not get my shell script to work. its dynamically generated with proper paths and all, so paths here are just placeholders for you. I also call chmod +x BASH_FILE. the content of shell script is valid since when I copy it to terminal it works.
mjml -r IN_PATH -o OUT_PATH;
probably I need to setup my .bash_profile differently. but I am not good at this.
cat ~/.bash_profile gives me…
export PATH="$PATH:$HOME/.rvm/bin:/usr/local/bin:~/.composer/vendor/bin" # Add RVM to PATH for scripting
script output is mjml: command not found. same with full path.
i did some research: maybe it has to do with chrooted apache like described here but I am not sure how to add /bin/sh to my MAMP Pro apache enviroment.
I don’t think your Apache is chrooted. That only really makes sense on servers and most admins who use such a setup don’t really understand security either. Having that in MAMP doesn’t make sense at all.
It also can’t be related to your $PATH. As I said, absolute paths to the binary should always work.
Could you please try running ls /usr/local/bin from PHP (replace the mjml command with it) and post the output here?
If I understand correctly, you want MAMP Pro to render the mjml into html on the fly? I would suggest simpler ways of doing this.
I have a local development server setup using Vagrant and Gulp that allows me to build and test emails with MJML locally, with live reload in the browser using Browsersync and email testing via MailGun. This lets me actually send it to an email address directly from my machine so that i can test it in a mail client. I can also test the emails being sent by the CMS system because Scotchbox contains Mailcatcher.
Personally, I gave up MAMP Pro a long time ago, because it caused great pain when it came to doing anything outside of the box. You will be much happier with a Vagrant based setup.
You can set this up quite easily. I would recommend Scotchbox as this is what I build Kirby sites with. It can be configured as a multisite setup using local domains. You just need to tweak the Scotchbox Multisite.
I’m happy to share my Gulp tasks that handle the compilation of the Emails & MailGun testing if you want.
Alternatively, I’m working on a development framework that will be publicly released soon that has this baked in. It is what i use to build Kirby sites.
Alternatively, if you don’t like the sound of all that, i’m assuming you are using NPM for package management? A lot of people don’t know that you can actually use NPM as a build tool. it allows you to execute shell commands prior, during and after build time. In theory you can get NPM to compile your MJML and the auto spin up your Mamp Server. There are plenty of guides on Google for using NPM as a build tool.
@lukasbestle seems only node.js stuff fails in php. all of them work in terminal.
/usr/local/bin/sass -h => works
/usr/local/bin/node -h => works. its a os-bin not a 'node'-bin.
/usr/local/bin/sass-lint -h => fails. its a link to a /node_module/ .js file
/usr/local/bin/bower -h => fails. its a /node_module/ bin
thanks for the in depth explanation. I will definitely take a look at it.
in my current case i am developing a plugin and wanted to keep the technical-setup-bar as low as possible for users of my plugin. oh, I will just use php exec to call mjml seemed simple enough at first.
No problem. I think the problem your having is that MAMP is not “real”, its a self contained, pre-packaged version of PHP, Apache and MySQL that is kind of set in stone. If you go the Vagrant route, your server is as if it was a live production server. That was the goal of Vagrant in the first place. If you need to update something you can just SSH in the Vagrant VM and upgrade just as you would on a production server.
Whilst it does take a few steps to get it running, it’s not that hard and I certainly don’t miss MAMP.