Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions README-SPANISH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Servidor PHP ejecutando en linea en Node.js
====================================

Preocupate, preocupate mucho, El nombre **NodePHP** se toma de el hecho de que estamos efectivamente volcando a buen servidor Node.js a una interfaz FastCGI que interactúa con PHP-FPM.

Este es omega-alfa-super-beta-prueba-de-concepto pero esta actualmente ejecutando unos pocos scripts simples. Parcialmente hecho para mis platicas sobre **Node.js para los desarrolladores de PHP** esta resulta ser un proyecto bastante interesante que estamos más probable es que vamos a utilizar con [Orchestra] (http://orchestra.io) cuando decidimos lanzar nuestra **Servidor en línea de PHP** que permite a las personas para ejecutar PHP sin Apache, Nginx o cualquier servidor web.

Sí, esto va en contra de todas las ideas y conceptos de Node.js, pero la idea es ser capaz de crear un servidor web directamente desde cualquier directorio de trabajo para permitir a los desarrolladores para ponerse en marcha incluso más rápido de lo que era antes.

No necesita crear un host virtual o bloques de servidor o modificar más tu /etc/hosts.

Sinopsis
--------
Este módulo Node.js se hace con el único propósito de mi platica de conferencia, sino que también para permitir a los desarrolladores
empezar a trabajar con PHP incluso más rápido de lo normal. Después de instalar este módulo de node, los desarrolladores tienen que asegurarse de que tienen PHP-FPM corriendo en algún lugar de su sistema. Si es así, ellos serán capaces de ir a cualquiera de sus directorios web (esos que el usuario FPM tiene acceso) y simplemente escriba 'node PHP' y desde allí se verá una poco bonita salida que luce como esto:

    bash$~ servidor PHP esta ahora corriendo en el puerto 9001
           Petición de entrada: GET /test.php
             -> Codigo de estatus de respuesta de petición: "200"

Esto se va a correr en el navegador permitiendole desarrollar y probar las aplicaciones más rápido. Ojalá el resultado final será **bifurcando** el proyecto y ayudando porque no tengo suficiente tiempo para hacer todo lo que quisiera hacer con esa cosa.


¿Qué?
-----
Le permite entrar en un directorio, escribir "node-php" y tener un servidor web en ejecución que sirve PHP. ¿Feliz?...


Instalación
----------
Bueno, esto es un poco difícil, hay algunas cosas que se necesitan en orden para conseguir esto en ejecución.

  - Necesitas un servidor PHP-FPM corriendo.
  - Necesitas tener instalado Node.js con la NGP
  - Instalar **node-fastcgi-parser** (https://github.com/billywhizz/node-fastcgi-parser)
  - A continuación, 'git clone git://github.com/davidcoallier/node-php.git', a continuación 'git submodule update', y`'npm install'.

Para esta versión beta, se supone que está corriendo FPM fuera de localhost en el puerto 9000. Si está corriendo a través de un **socket** tu puedes desear tu propio script que se veria así:

    Var = php require('nodephp');
    php.nodephp ({
        fcgi: {
            puerto: '/tmp/php-fpm.sock',
            host: null,
        },
        servidor: {
            puerto: 9998
        }
    });

Por favor recuerde que la conexión no ha sido probada aún. Todo lo que se ha probado es la conexión a una diferente puerto FastCGI e iniciar el servidor en un puerto diferente tal como:

    Var = php require('nodephp');
    php.nodephp ({
        fcgi: {
            puerto: 9001,
            host: 'localhost',
        },
        servidor: {
            puerto: 9111
        }
    });


Sirviendo archivos estáticos
--------------------
Liberarás suficientemente rápido que sólo se corriéndolo esto es bastante inútil, ya que no sirve archivos estáticos y semejantes. Esta es el porque el código **node-php** tiene la capacidad para definir **bloques** aunque bloques simples. Se definen en el segundo argumento de la llamada **node-php**:

    Var php = require('nodephp');
    php.nodephp ({
        fcgi: {
            puerto: 9001,
            host: 'localhost',
        },
        servidor: {
            puerto: 9111
        }
    }, {
        "\.(js|css|png|jpg|jpeg|gif|txt|less)$": php.NODEPHP_TYPE_STATIC,
        "\.php$": php.NODEPHP_TYPE_FCGI,
        "index": "index.php"
    });

Donde los siguientes son:

    NODEPHP_TYPE_STATIC: Archivos estáticos que no necesitan pasar por el controlador de fastcgi ( 'fastcgi_pass')
    NODEPHP_TYPE_FCGI: Archivos que usted envia a través del controlador de FCGI.

Si quieres más simplsa utilizando el 'localhost: 9000' por defecto para el manejador FCGI:

    var php = require('nodephp');
    php.nodephp ({}, {
        "\.(js|css|png|jpg|jpeg|gif|txt|less)$": php.NODEPHP_TYPE_STATIC,
        "\.php$": php.NODEPHP_TYPE_FCGI,
        "index": "index.php"
    });

Esperemos que esto ayuda.


Elementos & tareas
------------------
Hay algunos elementos muy importantes justo ahora:

  -No es un manejador de POST. No estoy tan lejos en las especificaciones de FCGI sin embargo - es necesario encontrar como enviar datos (datos de POST)
  - No hay una url **base**. Si incluyes ../../../../poop tratará de cargarlo y muy probablemente fallará.
  - Si intentas cargar un archivo que el trabajador PHP-FPM no tiene acceso, se producirá un error silencioso y maldeciras. Mucho. Por silencio me refiero, se le dará un 404 incluso aunque los archivos existan.


Renuncia
----------
Este es un prototipo feo y si lo ejecutas en producción, seras más probablemente retos mentales (No es que sea algo malo ..), pero no tomo ninguna responsabilidad de lo que puede hacer con el. Por otra parte, esto va en contra de todo lo que Node.js. Así que dense cuenta de eso.


Licencia
-------
Publicado bajo la nueva licencia BSD.

Copyright (C) 2011 David Coallier
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
Inline PHP Server Running on Node.js
====================================

Be worried, be very worried. The name **NodePHP** takes its name from the fact that we are effectively
turning a nice Node.js server into a FastCGI interface that interacts with PHP-FPM.
Be worried, be very worried. The name **NodePHP** takes its name from the fact that we are effectively turning a nice Node.js server into a FastCGI interface that interacts with PHP-FPM.

This is omega-alpha-super-beta-proof-of-concept but it already runs a few simple scripts. Mostly done
for my talks on **Node.js for PHP Developers** this turns out to be quite an interesting project that
we are most likely be going to use with [Orchestra](http://orchestra.io) when we decide to release our
**Inline PHP server** that allows people to run PHP without Apache, Nginx or any webserver.
This is omega-alpha-super-beta-proof-of-concept but it already runs a few simple scripts. Mostly done for my talks on **Node.js for PHP Developers** this turns out to be quite an interesting project that
we are most likely be going to use with [Orchestra](http://orchestra.io) when we decide to release our **Inline PHP server** that allows people to run PHP without Apache, Nginx or any webserver.

Yes this goes against all ideas and concepts of Node.js but the idea is to be able to create a web-server
directly from any working directory to allow developers to get going even faster than it was before. No
need to create vhosts or server blocks ore modify your /etc/hosts anymore.
Yes this goes against all ideas and concepts of Node.js but the idea is to be able to create a web-server directly from any working directory to allow developers to get going even faster than it was before. No need to create vhosts or server blocks ore modify your /etc/hosts anymore.

Synopsis
--------
This node.js module is made for the sole purpose of my conference talk but also to allow developers to
get started with PHP even faster than the usual. After installing this node-module, developers need to make
sure they have PHP-FPM running somewhere on their system. If it is, they will be able to go to any of their
web-directory (that the FPM user has access to) and simply type `node php` and from there they will see a
This node.js module is made for the sole purpose of my conference talk but also to allow developers to get started with PHP even faster than the usual. After installing this node-module, developers need to make
sure they have PHP-FPM running somewhere on their system. If it is, they will be able to go to any of their web-directory (that the FPM user has access to) and simply type 'node php' and from there they will see a
nice little output that looks like this:

bash$~ PHP Server is now running on port 9001
Incoming Request: GET /test.php
--> Request Response Status Code: "200"

This is going to be running in the browser allowing you to develop and test your applications faster. Hopefully
you will end up **forking** the project and helping out because I do not have enough time to do all I would want to
do with this thing.
This is going to be running in the browser allowing you to develop and test your applications faster. Hopefully you will end up **forking** the project and helping out because I do not have enough time to do all I would want to do with this thing.


What?
Expand All @@ -44,8 +35,7 @@ Well this is a bit tricky, there are a few things you will need in order to get
- Install **node-fastcgi-parser** ( https://github.com/billywhizz/node-fastcgi-parser )
- Then you `git clone git://github.com/davidcoallier/node-php.git`, then you `git submodule init`, then you `git submodule update`, and `npm install`

For this beta version, we assume that you are running FPM off `localhost` on port `9000`. If you are running
through a **socket** you may want to make your own script that looks like this:
For this beta version, we assume that you are running FPM off `localhost` on port `9000`. If you are running through a **socket** you may want to make your own script that looks like this:

var php = require('nodephp');
php.nodephp({
Expand All @@ -58,8 +48,7 @@ through a **socket** you may want to make your own script that looks like this:
}
});

Please note that the sock connection has not been tested yet. All that has been tested is connecting to a different
FastCGI port and starting the server on a different port like such:
Please note that the sock connection has not been tested yet. All that has been tested is connecting to a different FastCGI port and starting the server on a different port like such:

var php = require('nodephp');
php.nodephp({
Expand All @@ -75,8 +64,7 @@ FastCGI port and starting the server on a different port like such:

Serving Static Files
--------------------
You will realise rapidly enough that only running this is quite useless as it does not serve static files and such. This is why the **node-php**
code has the abiliyt to define **blocks** — albeit simple blocks. They are defined in the second argument of the nodephp call:
You will realise rapidly enough that only running this is quite useless as it does not serve static files and such. This is why the **node-php** code has the abiliyt to define **blocks** — albeit simple blocks. They are defined in the second argument of the nodephp call:

var php = require('nodephp');
php.nodephp({
Expand Down Expand Up @@ -121,8 +109,7 @@ There are a few very important issues right now:

Disclaimer
----------
This is an ugly prototype and if you run this in production you are most likely mentally challenged (Not that it's a bad thing..) but
I take no responsibility for what you do with this. Moreover, this goes against everything Node.js stands for. So realise that.
This is an ugly prototype and if you run this in production you are most likely mentally challenged (Not that it's a bad thing..) but I take no responsibility for what you do with this. Moreover, this goes against everything Node.js stands for. So realise that.


License
Expand Down