Logging the contents of a file, and printing some random stuff:
JS (in node):
var fs = require('fs');
fs.readFile('/foo.txt', function(contents) {
console.log(contents);
});
setTimeout(function() { | |
console.log("2 seconds"); | |
}, 2000); | |
setTimeout(function() { | |
console.log("now??"); | |
}, 0); | |
console.log("now"); |
Logging the contents of a file, and printing some random stuff:
JS (in node):
var fs = require('fs');
fs.readFile('/foo.txt', function(contents) {
console.log(contents);
});
var logSomething = function(something) { | |
console.log(something); | |
}; | |
function do_math(foo, bar, baz) { | |
return foo + bar + baz; | |
}; | |
function do_math_then(foo, bar, baz) { |
<?php | |
namespace AC\Fixtures; | |
/** | |
* Factories use Definitions and Pools to create and store (not persist) object instances. | |
*/ | |
interface Factory | |
{ | |
public function define($name); //create and returns Definition |
<?php | |
trait Methods | |
{ | |
public function __call($name, $args) | |
{ | |
if (property_exists($this, $name)) { | |
return $this->$name; | |
} |
Symfony2 and Angular.js make a great, robust combintaion. Integrating them isn't immediately obvious, however. Both communities come with their own standards and suite of tools for managing the development process, and sometimes those tools conflict.
On the Symfony side, you mainly deal with composer for managing your dependencies, a few Symfony commands in your project, and any other tools you add into the mix, like phpunit.
On the Angular side, you'll probably end up using npm, bower and probably grunt for automating some of the pain.
The original blog post can be found here: http://blog.brunoscopelliti.com/building-a-restful-service-with-angularjs-and-php-backend-setup. I've tried to keep the logic the same as the original post.
Write a composer.json
, and require Silex. If you don't know about composer, you can learn about it at getcomposer.org. It's a package manager for PHP like NPM for node, most major projects now use this for managing dependencies.
{
Temp/ | |
Library/ | |
obj/ | |
*.svd | |
!Library/*.asset | |
!Library/AssetImportState | |
!Library/AssetVersioning.db | |
!Library/BuildPlayer.prefs | |
!Library/ScriptMapper |