Deploying on PHP / Apache

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Deploying on PHP / Apache

Spyryto
Hi!
My name is Daniele and I'm a web developer and musician.
I am really excited by the never-ending surprise that is Smalltalk and the genius people that created it, love it and use it.

At the web agency I work at our current server stack is LAMP for pretty much EVERY customer we have.

While I can have node.js running on my development machine, I will not have it installed on the server.
I know that one can deploy Amber apps just by uploading on the server the required .js files, but it seems to me that way one loses the ability to Commit Package to disk, thus making Helios quite useless.

The problem, it seems, is Apache cannot deal properly with PUT requests. As I see, a PUT request should make the webserver create a file on the filesystem and set its content, while in fact it fails badly.
I have done some research and I think this is a well-spread bug or, at least, a misunderstanding in using HTTP requests.

So what I have done is the following.

In package Kernel-ImportExport, class PackageHandler, the method for exporting a package is rewritten with a JQuery POST request.

ajaxPutAt: aURL data: aString onSuccess: aBlock onError: anotherBlock
    jQuery
        ajax: #{
            'url' -> '/.spyral/save.php'.  "This is explained below"
            'type' -> 'POST'.
            'data' -> #{
                'file' -> aURL.
                'content' -> aString
            }.
           
            "'contentType' -> 'text/plain;charset=UTF-8'."
           
            'success' -> aBlock.
            'error' -> anotherBlock
        }


The aforementioned save.php file contains the following code

<?php
    exit (
        nl2br (
            parse_url ( $_POST['file'], PHP_URL_PATH )
            . ': '
            . file_put_contents(__DIR__ . '/../'. parse_url($_POST['file'], PHP_URL_PATH), $_POST['content'])));



It seems to work, though this code is not well tested... i.e. it does not deal well with errors.

What I am asking is this: is the amber community interested in a server-agnostic deployment system, or is the toolchain too heavily based on node.js?
Is anybody interested in making this thing work, or, at least, suggest me a way to keep my modification through repository upgrades?
Should I fork the project?

Anything welcome.
Keep up the good work and have fun!

Bye,
Daniele

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying on PHP / Apache

Herby Vojčík
Hello!

You do not need node.js at all if you do not want to. You can develop
in any server which has PUT enabled (apache / nginx / whatever).

OTOH, amber-cli contains a lot more than `amber serve`. It has `amber init` to initialize project, it has `amberc` command-line compiler, and in upcoming 0.13 line of amber, the amd configuration of the project will be assembled by `amber config`. Plus, `amber init`ed project include Gruntfile.js prepared with tests and recompiling.

So, if you do not mind to lose all the other helper tooling, you can go without node.js. The main thing - committing packages - does not need it, any server will do (without any rewrite of PackageHandler etc.).

Herby

Spyryto wrote:
> Hi!
> My name is Daniele and I'm a web developer and musician.
> I am really excited by the never-ending surprise that is Smalltalk and
> the genius people that created it, love it and use it.
>
> At the web agency I work at our current server stack is LAMP for
> pretty m
uch EVERY customer we have.

>
> While I can have node.js running on my development machine, I will not
> have it installed on the server.
> I know that one can deploy Amber apps just by uploading on the server
> the required .js files, but it seems to me that way one loses the
> ability to Commit Package to disk, thus making Helios quite useless.
>
> The problem, it seems, is Apache cannot deal properly with PUT
> requests. As I see, a PUT request should make the webserver create a
> file on the filesystem and set its content, while in fact it fails badly.
> I have done some research and I think this is a well-spread bug or, at
> least, a misunderstanding in using HTTP requests.
>
> So what I have done is the following.
>
> In package Kernel-ImportExport, class PackageHandler, the method for
> exporting a package is rewritten with a JQuery POST request.
>
> ajaxPutAt: aURL data: aString onSuccess: aBlock onError: anotherBlock
> jQuery
> ajax: #{
> 'url' -> '/.spyral/sa
ve.php'. "This is explained below"

> 'type' -> 'POST'.
> 'data' -> #{
> 'file' -> aURL.
> 'content' -> aString
> }.
>
> "'contentType' -> 'text/plain;charset=UTF-8'."
>
> 'success' -> aBlock.
> 'error' -> anotherBlock
> }
>
> The aforementioned save.php file contains the following code
>
> <?php
> exit (
> nl2br (
> parse_url ( $_POST['file'], PHP_URL_PATH )
> . ': '
> . file_put_contents(__DIR__ . '/../'. parse_url($_POST['file'],
> PHP_URL_PATH), $_POST['content'])));
>
>
> It seems to work, though this code is not well tested... i.e. it does
> not deal well with errors.
>
> What I am asking is this: is the amber community interested in a
> server-agnostic deployment system, or is the toolchain too heavily
> based on node.js?
> Is anybody interested in making this thing work, or, at least, suggest
> me a way to keep my modification through repository upgrades?
> Should I fork the project?
>
> Anything welcome.
> Keep up the good work and have fun!
>
> Bye,
> Daniele
>

> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying on PHP / Apache

Herby Vojčík
In reply to this post by Spyryto


Spyryto wrote:
> Hi!

> The problem, it seems, is Apache cannot deal properly with PUT requests.
> As I see, a PUT request should make the webserver create a file on the
> filesystem and set its content, while in fact it fails badly.
> I have done some research and I think this is a well-spread bug or, at
> least, a misunderstanding in using HTTP requests.

Missed this part (the mail was long). Well, maybe it is really so that
people misunderstand PUT, surely Amber uses it as "SAVE file", but
instead of rewriting that part, I would just play with configuration. It
should be possible to set the script that handles PUT request, limit
them to directory etc. I personally did not do this, as I use `amber
serve`, so I am only repeating what was told to me - just set up any
server which does PUT by saving a file; and I believe it should be able
to set this up (maybe with some tweaking a server config, but doable).

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying on PHP / Apache

Spyryto
Thanks Herby!

if you do not mind to lose all the other helper tooling, you can go without node.js

I see. I was wondering if sooner or later all of this will be implemented in smalltalk code and self-contained. I mean, having all the config logic inside Amber and kind of "exporting" config to disk with PUT or similar.
I am doing something similar with Javascript, where I process the page markup and then cache it to disk into a .html file using the PHP one-liner.

maybe it is really so that
people misunderstand PUT, surely Amber uses it as "SAVE file", but
instead of rewriting that part, I would just play with configuration. It
should be possible to set the script that handles PUT request, limit
them to directory etc.

That was the first thing I tried, but I did not find reliable material on the topic, and it was not easy to find too.

Spyryto

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying on PHP / Apache

Herby Vojčík


Spyryto wrote:
> Thanks Herby!
>
>     if you do not mind to lose all the other helper tooling, you can
>     go without node.js
>
>
> I see. I was wondering if sooner or later all of this will be
> implemented in smalltalk code and self-contained. I mean, having all

It _is_ implemented in smalltalk code. But to run amber (smalltalk compiled to js) application in cli you need node.js (javascript for cli).

That said, amberc is still lots of javascript, but `amber` tool itself (with init, server, config etc.) is written in Amber (AmberCli package, external/amber-cli in repo).

> the config logic inside Amber and kind of "exporting" config to disk
> with PUT or similar.

Well, ... maybe. Then you're confined to browser IDE.. CLI is useful for things like CI, that's why amber projects can be compiled by grunt, configured by amber config (or grunt, if someone writes the task), tested by 'npm test' which just calls 'grunt test' etc.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.