Re: plack psgi
by Corion (Patriarch) on Feb 09, 2023 at 13:44 UTC
|
plackup is when you want to run an application written using Plack as a stand-alone server.
If you want to run an application implemented using Plack within your "normal" webserver as a subprogram, it is just a matter of setting up .htaccess (or the moral equivalent of your webserver) to execute the .psgi file.
I don't use CPanel, so I don't really know if/how they install the plackup program, but if you want your program to appear as an URL below the "normal" webserver on port 80, you want to go the .psgi way and not use plackup.
| [reply] [d/l] [select] |
|
Very informative! Thanks.
| [reply] |
Re: plack psgi
by hippo (Bishop) on Feb 09, 2023 at 14:49 UTC
|
I have to say that am I hosted on a shared host that uses CPanel.
This sounds very much like you will not have access to a persistent back-end. In that case you should be aware that running Plack-based applications without a persistent back-end incurs a significant performance penalty. See this old but still relevant discussion which also lists some lighter alternatives.
If somehow you can run a persistent back-end then yes, that's going to be faster. In that scenario, using a PSGI-based solution (plack or otherwise) effectively de-couples your code from any one specific front-end so it would be the way to go.
| [reply] |
|
I'm not sure what you mean by "persistent back-end". My hosting runs on Apache and I have access to all perl/cpan stuff. Do mean persistent in terms of DB? If that is the case I have access to postgres, mysql, sqlite etc.
Thanks for the info in any case!
| [reply] |
|
I get what you mean by persistent now, thanks.
| [reply] |
Re: plack psgi
by erickp (Acolyte) on Feb 09, 2023 at 16:32 UTC
|
Guys, maybe I'm not going about it the right way, seems like I am not from some of your comments, I get it.
Here's the why and what I'm after :
- I've been coding web stuff on and off since 1847, went from ASP to Java to PHP to Wordpress and now I'm trying Perl. Yes I'm a late bloomer it seems.
- I'm used to the way of simply inserting tags of code in html, like PHP or ASP or JSP etc...that's what I gravitate towards to naturally. That's how I've learned. I like that concept, even if some folks hate the fact of mixing logic and presentation together. I shamelessly don't find that to be an issue for me, makes it actually easier for me. I like it.
- I am NOT used to the "new" way of doing "apps" like what is done in nodejs-type languages. To me Mojo, Dancer etc. are all in that same vein. It's not that I'm against it, I just don't prefer that way of working from the get go, not familiar to me. I like the familiar.
- Also, doing something lower level (psgi/cgi) for me is also a way of learning how things work under the hood, I like that. Yes there are "security" risks for me in doing so. I don't mind burning myself while learning how to code securely. To me that's part of learning how to do things right. Why do you think the creator(s) of Mojo or other frameworks created their own in the first place. The argument that something else already exists wasn't an option for them either. People never think they should re-invent the wheel, until they do, every 10 years or so.
- Basically I just love the Perl language and I'm trying to learn it as "vanilla" as I can for now. I was just going to use CGI.pm but then learned about psgi so...I'll start with that. Perhaps in 2 weeks I'll come to my senses and use a "real" framework, who knows!
Again, not bashing the "other" ways of working or other frameworks. I just try to stick to concepts I already know if I can, better for my aging brain.
Thanks. | [reply] |
|
I'm used to the way of simply inserting tags of code in html, like PHP or ASP or JSP etc...that's what I gravitate towards to naturally. That's how I've learned. I like that concept, even if some folks hate the fact of mixing logic and presentation together. I shamelessly don't find that to be an issue for me, makes it actually easier for me. I like it.
I started with ASP and ColdFusion, I'm happy to report that Mojo allows you to include perl code in templates (containing HTML/JS etc). Guides -> Embedded Perl. You'll find this familiar.
I appreciate what you're saying with the remainder of your response. There's validity in the point you make about reinventing the wheel, from the Mojo homepage:
"Mojolicious is a fresh take on Perl web development, based on years of experience developing the Catalyst framework, and utilizing the latest web standards and technologies. "
If you change your mind, I'd suggest getting started with Mojolicious:::Lite, (Tutorial), you get to keep it simple in terms of the organisation of your code, and get great benefits provided by the framework, and I honestly think the learning curve isn't particularly steep given your past experience. With this in mind the responses to Switching from PHP to Perl/Mason from a few days ago are perhaps more along the lines that you're thinking of now.
Update: derp, you created the previous thread...
| [reply] |
|
Thanks for the response! Appreciated!
| [reply] |
|
Hello erickp,
> I've been coding web stuff on and off since 1847
Please dont change this typo (hoping this is typo ;) because it made me laugh a lot and saved my friday morning in a boring office.
In exchange I offer you some, maybe interesting, link from my bibliotheca about plack, psgi, migrating from CGI and web programming in general.
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] |
|
Might be not a typo, but simply meaning "since the year dot".
What does this have to do with Abraham Lincoln?
Everything.
After all, it was he who proclaimed on June 2, 1861, that “The problem with information that you read on the Internet is that it is not always true.”
-- (Source)
| [reply] |
|
| [reply] |
|
You forgot to close italics over there
| [reply] |
|
I'm used to the way of simply inserting tags of code in html, like PHP or ASP or JSP etc...that's what I gravitate towards to naturally
Others have suggested Mojolicious and I will throw Template in as a suggestion. It handles all the display for you through templates (there's a surprise from the name!) but without changing the underlying Perl language.
If you want to include Perl in your templates you can - either as a sub which the template calls or directly embedding the Perl.
I'm not a user of Mojolicious so I may be mistaken, but it seems to me that Template is easier to learn if you already know Perl. I have certainly not found anything I want to do with web and email programming that Template cannot handle. I think it was hippo who introduced me to Template - for this I will be grateful to the end of my days...
| [reply] [d/l] |
Re: plack psgi
by 1nickt (Canon) on Feb 09, 2023 at 13:45 UTC
|
"I'm trying to avoid frameworks like Dancer/Mojolicious"
Why? The whole point of such frameworks is to hide away the type of problems that you are currently struggling with. Which allows you to write code describing your logic instead.
I don't feel like I "have to" use Dancer2, I feel like I get to.
The way forward always starts with a minimal test.
| [reply] |
|
I second this argument. We see it time and time again, 'I don't want to use some bloated framework like xyz...' followed by several posts from the same user about how to stop tripping up over issues getting started like this, reinventing the wheel while almost without fail making it worse, introducing security flaws or other related masochistic behaviours. People I know who have retro computing for a hobby keep that passion separate from their day jobs, where getting things done matters more than struggling with out dated cruft.
| [reply] |
Re: plack psgi
by LanX (Saint) on Feb 09, 2023 at 13:43 UTC
|
| [reply] |
|
| [reply] |
|
> Didn't Mojolicious reinvent every known wheel to avoid CPAN dependencies? ☺
That's the point, the OP doesn't need to reinvent what SRI already packaged into mojo...
| [reply] |
|
yes, looks more and more like the way to go...I might just do that.
| [reply] |
|
|
|