digitalmars.D.learn - vibe.d Subdirectory?
- seany (18/18) Jan 14 2015 I am new to vibe.d and plying a bit with it.
- Rikki Cattermole (8/25) Jan 14 2015 Vibe.d is not a web server. It is a web server framework.
- ketmar via Digitalmars-d-learn (15/38) Jan 14 2015 thing about vibe.d as "node.js made right". it's not a ready-to-go
- seany (11/13) Jan 14 2015 Actually I want to serve some JSON packed weather data (heck I
- ketmar via Digitalmars-d-learn (9/24) Jan 14 2015 you still thinking the wrong way. vibe.d IS NOT A WEB-SERVER. and it's
- Laeeth Isharc (18/26) Jan 14 2015 Cool. Do you incorporate the influence of solar activity via
- Laeeth Isharc (9/28) Jan 14 2015 To be very clear: in the simple case when you compile your vibe
- Steven Schveighoffer (12/17) Jan 15 2015 Pardon me for asking kind of a side question, but is there any online
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (9/11) Jan 15 2015 If you are going to replace php then you probably want to have
- Dicebot (10/22) Jan 15 2015 Generally easiest way is to make Apache forward some of URLs to
- Adam D. Ruppe (9/9) Jan 15 2015 If your php stores sessions in files, you can just read those
- Laeeth Isharc (13/33) Jan 15 2015 It may be that you have a reason for going with apache, but in
- Steven Schveighoffer (2/2) Jan 15 2015 Thanks everyone for the tips.
I am new to vibe.d and plying a bit with it. I notice, that in case of Apache, there is a "root" directory, often by default under /var/www or /srv/http (resp. ftp) if you are using linux, and then every time the client sends a request, apache looks in to the root directory, deduces the subdirectory from the URI, and pulls the page up from there. Then it parses the PHP / other scripting commands, and prints the HTML as is, before serving it over http. I want to know the equivalent of all these in vibe.d. The website has a documentation, but all what I find is that you will need an app.d, in a predefined directory structure. I however, do not understand, what the root directory is going to be. Is it going to be the directry where vibe.d is started? Say, I start my vibe.d under /server, then I have an app.d under /server/a/app.d and /server/b/app.d Do I access them via http://top.level.domain/a, resp /b, and app.d is like index.html / index.php which vibe.d looks for by default, or do i have to use http://top.level.domain/a/app.d
Jan 14 2015
On 15/01/2015 12:40 a.m., seany wrote:I am new to vibe.d and plying a bit with it. I notice, that in case of Apache, there is a "root" directory, often by default under /var/www or /srv/http (resp. ftp) if you are using linux, and then every time the client sends a request, apache looks in to the root directory, deduces the subdirectory from the URI, and pulls the page up from there. Then it parses the PHP / other scripting commands, and prints the HTML as is, before serving it over http. I want to know the equivalent of all these in vibe.d. The website has a documentation, but all what I find is that you will need an app.d, in a predefined directory structure. I however, do not understand, what the root directory is going to be. Is it going to be the directry where vibe.d is started? Say, I start my vibe.d under /server, then I have an app.d under /server/a/app.d and /server/b/app.d Do I access them via http://top.level.domain/a, resp /b, and app.d is like index.html / index.php which vibe.d looks for by default, or do i have to use http://top.level.domain/a/app.dVibe.d is not a web server. It is a web server framework. Make it however you feel like! P.S. People will say it isn't a web server framework that its also a web service framework and yada ya. But web server framework is a better way of thinking of it :) Also a bit of bloat that includes web service framework and more IO stuff.
Jan 14 2015
On Wed, 14 Jan 2015 11:40:25 +0000 seany via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:I am new to vibe.d and plying a bit with it. =20 I notice, that in case of Apache, there is a "root" directory,=20 often by default under /var/www or /srv/http (resp. ftp) if you=20 are using linux, and then every time the client sends a request,=20 apache looks in to the root directory, deduces the subdirectory=20 from the URI, and pulls the page up from there. Then it parses=20 the PHP / other scripting commands, and prints the HTML as is,=20 before serving it over http. =20 I want to know the equivalent of all these in vibe.d. The website=20 has a documentation, but all what I find is that you will need an=20 app.d, in a predefined directory structure. I however, do not=20 understand, what the root directory is going to be. =20 Is it going to be the directry where vibe.d is started? =20 Say, I start my vibe.d under /server, then I have an app.d under=20 /server/a/app.d and /server/b/app.d =20 Do I access them via http://top.level.domain/a, resp /b, and=20 app.d is like index.html / index.php which vibe.d looks for by=20 default, or do i have to use http://top.level.domain/a/app.dthing about vibe.d as "node.js made right". it's not a ready-to-go webserver, it's more like an async i/o framework that can be used to build any server you want. so you have to write your own dispatcher (it's actually very easy for easy cases, just consult vibe.d documentation) to get the things you want. that dispatcher can provide pages from disk, from some db, build them on the fly and so on. it's up to you how it will work. yes, this is more complicated than just setting up ready-to-work webserver, but... but why you want your own simple web-server anyway? just use one of the already written ones. and if you want some special processing which you done with some scripting language like PHP for "traditional setup", vibe.d starts shining: just forgot about that crappy scripting stuff and write your code in D!
Jan 14 2015
On Wednesday, 14 January 2015 at 12:25:12 UTC, ketmar via Digitalmars-d-learn wrote:just forgot about that crappy scripting stuff and write your code in D!Actually I want to serve some JSON packed weather data (heck I also wrote my Global Climate Model partially in D and in C) - so I guess, I can use vibe.d to build a cgi. However I also want to recieve some userinput, and parse it - and sometimes, php is simpler, because for a very small parsing task you dont want to worry abotu types and all. Does vibe.d support any HTML Preprocessor in the first place? If not PHP then Neco? Falcon? So that I do not always have to access my vibe.d based app, but I can simply change the page itself a bit?
Jan 14 2015
On Wed, 14 Jan 2015 12:37:33 +0000 seany via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Wednesday, 14 January 2015 at 12:25:12 UTC, ketmar via=20 Digitalmars-d-learn wrote:you still thinking the wrong way. vibe.d IS NOT A WEB-SERVER. and it's not a cgi wrapper. if you're looking for fancy web-server with cgi support and so on, but written in D, you got the wrong app. vibe.d is a *framework* that will allow you to write your own web server. what you get is toolbox to build your server, but not the server itself. so vibe.d supports *everything* -- you just have to write the code for it!just forgot about that crappy scripting stuff and write your code in D!=20 Actually I want to serve some JSON packed weather data (heck I=20 also wrote my Global Climate Model partially in D and in C) - so=20 I guess, I can use vibe.d to build a cgi. =20 However I also want to recieve some userinput, and parse it - and=20 sometimes, php is simpler, because for a very small parsing task=20 you dont want to worry abotu types and all. Does vibe.d support=20 any HTML Preprocessor in the first place? If not PHP then Neco?=20 Falcon? So that I do not always have to access my vibe.d based=20 app, but I can simply change the page itself a bit?
Jan 14 2015
Actually I want to serve some JSON packed weather data (heck Ialso wrote my Global Climate Model partially in D and in C) - so I guess, I can use vibe.d to build a cgi.Cool. Do you incorporate the influence of solar activity via galactic rays / cloud formation and via volcanic activity? (This is not my field, but I am looking for a model that does).However I also want to recieve some userinput, and parse it - and sometimes, php is simpler, because for a very small parsing task you dont want to worry abotu types and all. Does vibe.d support any HTML Preprocessor in the first place? If not PHP then Neco? Falcon? So that I do not always have to access my vibe.d based app, but I can simply change the page itself a bit?It won't be quicker to write the parsing code in D if you are new to the language, but it is still pretty quick when you know how. There are regexes etc too. What Ketmar says. For a robust application it might be better to put it behind a proxy like nginx anyway. In which case you can use your vibed application to serve up parts of your site and php for others. Eg user submits a form and the result is posted to a url that nginx routes to your vibed app. You could dispense entirely with the web server and do the whole thing in vibed, but you don't need to. Although its a framework, you don't have to do much to turn it into a web server if you look at the documentation on the vibed page. The forum there is also quite helpful. Laeeth
Jan 14 2015
On Wednesday, 14 January 2015 at 11:40:26 UTC, seany wrote:I am new to vibe.d and plying a bit with it. I notice, that in case of Apache, there is a "root" directory, often by default under /var/www or /srv/http (resp. ftp) if you are using linux, and then every time the client sends a request, apache looks in to the root directory, deduces the subdirectory from the URI, and pulls the page up from there. Then it parses the PHP / other scripting commands, and prints the HTML as is, before serving it over http. I want to know the equivalent of all these in vibe.d. The website has a documentation, but all what I find is that you will need an app.d, in a predefined directory structure. I however, do not understand, what the root directory is going to be. Is it going to be the directry where vibe.d is started? Say, I start my vibe.d under /server, then I have an app.d under /server/a/app.d and /server/b/app.d Do I access them via http://top.level.domain/a, resp /b, and app.d is like index.html / index.php which vibe.d looks for by default, or do i have to use http://top.level.domain/a/app.dTo be very clear: in the simple case when you compile your vibe application from multiple source files and diet templates etc, and you will end up with an executable. This can act as a server directly, or you can make it an internal server on localhost called by php, or you can call it from nginx as a CGI type application depending on the URL. The vibed directory layout is of no relevance after compilation (unless you put your static data there).
Jan 14 2015
On 1/14/15 11:31 AM, Laeeth Isharc wrote:To be very clear: in the simple case when you compile your vibe application from multiple source files and diet templates etc, and you will end up with an executable. This can act as a server directly, or you can make it an internal server on localhost called by php, or you can call it from nginx as a CGI type application depending on the URL.Pardon me for asking kind of a side question, but is there any online information on how to do this? I am contemplating migrating my in-house php-based application to vibe.d, but I wondered if I have to do it whole-sale (not much gratification until the whole thing is done) or piecemeal (then some parts are php, some are vibe.d, until whole thing is ported). I thought I could do the latter, but I don't know how to interact apache/php with vibe.d. The biggest question I have is how vibe.d and php can share session data. But I also have no idea which server should be in front, and how to call one another ;) Thanks -Steve
Jan 15 2015
On Thursday, 15 January 2015 at 14:38:16 UTC, Steven Schveighoffer wrote:vibe.d and php can share session data. But I also have no idea which server should be in front, and how to call one another ;)If you are going to replace php then you probably want to have the d-server in front and just relay requests to the php server? If you create your own session solution on the d-server I'd just create a mapping to php-sessions so that you can map back an forth when relaying. That way you can replace php bit-by-bit and eventually phase it out.
Jan 15 2015
On Thursday, 15 January 2015 at 14:38:16 UTC, Steven Schveighoffer wrote:Pardon me for asking kind of a side question, but is there any online information on how to do this? I am contemplating migrating my in-house php-based application to vibe.d, but I wondered if I have to do it whole-sale (not much gratification until the whole thing is done) or piecemeal (then some parts are php, some are vibe.d, until whole thing is ported). I thought I could do the latter, but I don't know how to interact apache/php with vibe.d. The biggest question I have is how vibe.d and php can share session data. But I also have no idea which server should be in front, and how to call one another ;) Thanks -SteveGenerally easiest way is to make Apache forward some of URLs to vibe.d process (acting as HTTP proxy) while keeping to serve remaining PHP scripts. The more gets implemented in vibe.d process, the more URLs can be forwarded. I am not sure about session data part though. Quite likely you will need to implement session storage as a dedicated persistent process that gets queried by both vibe.d and PHP script. But this is not my domain of knowledge.
Jan 15 2015
If your php stores sessions in files, you can just read those files from D. Though that's horribly slow and I don't think php does that by default any more. But it really depends on how the PHP is configured to see how easy it will be. It might just be a cookie to read then index into a database, or maybe a signed cookie too... no way to tell without looking at the actual thing. But the php session formats, however they are stored, aren't terribly complex so you should be able to get into it.
Jan 15 2015
On Thursday, 15 January 2015 at 14:38:16 UTC, Steven Schveighoffer wrote:On 1/14/15 11:31 AM, Laeeth Isharc wrote:It may be that you have a reason for going with apache, but in case you have not looked into it (or the situation has changed since you last looked), you might consider nginx as a front end given better stability and performance. If you make D read the PHP authentication then you need to write a new auth scheme when you have gotten rid of PHP. So it might be worth at some point considering moving this to an external service called by both D and PHP when you can do so without breaking anything. This might be worth a read: http://merbist.com/2012/04/04/building-and-implementing-a-single-sign-on-solution/To be very clear: in the simple case when you compile your vibe application from multiple source files and diet templates etc, and you will end up with an executable. This can act as a server directly, or you can make it an internal server on localhost called by php, or you can call it from nginx as a CGI type application depending on the URL.Pardon me for asking kind of a side question, but is there any online information on how to do this? I am contemplating migrating my in-house php-based application to vibe.d, but I wondered if I have to do it whole-sale (not much gratification until the whole thing is done) or piecemeal (then some parts are php, some are vibe.d, until whole thing is ported). I thought I could do the latter, but I don't know how to interact apache/php with vibe.d. The biggest question I have is how vibe.d and php can share session data. But I also have no idea which server should be in front, and how to call one another ;)
Jan 15 2015