Why do we have the dollar sign before every php variable?

Is there anything like CoffeeScript for PHP?

  • PHP interpreters are very common, but the PHP syntax & libraries are inconsistent & cumbersome (IMO, of course). I think a language that compiles into PHP but provides higher level level features (like, modules, mixins, list comprehensions, etc...) and easier syntax (like optional semicolons, implied returns, no dollar sign for variables, optional brackets and braces, etc...) would be valuable. Does anything like this exist?

  • Answer:

    You might want to check the php-snow project. It's like coffeescript, but not coffeescript. It has its own syntax. http://code.google.com/p/php-snow/ It seems that php-snow is no longer active. Another one that I've tried that's still being actively worked on is https://github.com/unu/ladyphp. It's pretty good.

Jesus Domingo at Quora Visit the source

Was this solution helpful to you?

Other answers

Mike Cantelon

The pressure to produce such solutions are less than in the ecosystem, because on the browser you traditionally can't run native code*; but on any server where you can run , you can generally run native code (at least if it's your server) so there is little technical reason why you can't directly switch to a higher level language and not use PHP as an intermediate. For example, , which can be compiled to native code. But it sounds like you really want or, say, . If you don't want to run the standard interpreters for some reason, have you considered language front-ends targeting the ? Update: I am not endorsing this—I think it's a myopic and futile idea—but you might be interested in http://code.google.com/p/phpreboot/ *—but see Google NaCl: http://code.google.com/chrome/nativeclient/

Toby Thain

As of today, I would suggest looking at these:  - Haxe: http://haxe.org/  - Pharen: http://scriptor.github.com/pharen/ Haxe has been deployed to production and has quite a community, although with controversial reviews, mostly due to the fact that its wide scope, as it aims to compile to different languages (not only PHP), might complicate things for some people. Pharen mimics a Lisp-like language, looks promising, although with few people working on it (maybe 2), and lacking real data about usage in production environments (as of beginning of 2011). You can get more information about a similar question here: http://programmers.stackexchange.com/questions/36241/your-experience-with-haxe-and-other-languages-that-compile-to-php

David Riccitelli

This is EXACTLY what you're looking for: http://mammouth.wamalaka.com

Luis M. Gonzalez

You might want to take a step back and ask why you would need something CoffeeScript-like that compiles to PHP at all. If you find that PHP isn't working for you, so much so that you wish it was something else, why not just use something else? You shouldn't feel like you are locked into a single development platform. Unless you'll be fired for handing over code that doesn't smell like PHP. If that's the case, I'll leave the soul searching to you. CoffeeScript and node.js are best buddies, and node.js runs server-side just like PHP (only different). If you like the way CoffeeScript works you would be far better off embracing it fully. And it sounds like what you really want deep down. You don't have to break up with PHP to start hanging out with node.js (or Scala, or Ruby, or all of them together), you are in a totally open relationship, they all get along with each other. Maybe a little tiff here and there, but you'll be able to smooth it over. Without knowing your particulars, pick the best tool for the job and consider using what you feel most comfortable with, you'll be happier and more productive in the long run.

Ian White

Not that I'm aware of, but I think some would find it useful. Just like a CoffeeScript/JavaScript app can work on many browsers with zero configuration by the user, a LAMP app can work on many hosting accounts with very little configuration by the site owner. This is right down to the .htaccess and standardizing on MySQL. There are hundreds of open source PHP apps written this way. I also think it might be nice to automatically generate parameterized queries just like CoffeeScript does string interpolation.

Ben Atkin

This is just my personal opinion of the preprocessors that have made their way into front-end development and web design over the past few years (namely SASS, LESS, HAML, CoffeeScript, etc). Personally, I like them a great deal. They allow me to churn out a lot of HTML, CSS and JavaScript in a very short time. But consider that PHP can be written in an object oriented manner. This allows the programmer a level of abstraction that is simply not present in HTML, CSS and to some degree plain old vanilla JS. This is not to say that it can't be done, but if you're compelled to use PHP in your project, wouldn't a framework like Zend, CodeIgniter or Laravel better suit your needs?

Michael Kornblum

We're currently working on Gutscript (a language that compiles to PHP) please see http://github.com/c9s/gutscript

Yo-An Lin

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.