- 論壇徽章:
- 0
|
Catalyst 內(nèi)置了web服務(wù)器,看來使用Nginx作為生產(chǎn)環(huán)境的Web服務(wù)器比較好,一直沒有搞清楚兩者如何結(jié)合?
看了一些資料,感覺Nginx通過配置和一個fastcgi后臺運行的守護進程進行交互,由這個守護進程和catalyst框架通訊實現(xiàn)。
還有一個疑問,如果我的前端使用dojo toolkit,這個框架直接在那些tt2文件中使用就可以了?雌饋砗唵,但是整體的各個組件如何相互協(xié)作需要搞清楚?
我咨詢了Catalyst的作者,他是這樣回答的:
Catalyst, unlike a framework like say Ruby on Rails, sits at the center of a number of other Perl technologies. You named a few, such as Plack/PSGI, Template Toolkit, etc. Others might include DBIx::Class for interfacing with a database. And of course any number of testing tools on the Test::* namespace. As a result you have to put together a stack that makes sense to you, although one of the more common ones would be those mentioned.
Plack is an implementation of the PSGI specification, which connections a web application (such as Catalyst) to a web server, such as Nginx, Apache, Starman, etc. This glue layer is reusable across many web frameworks, so we all work on it together for the betterment of all. Plack also implements common middleware for concerns that are cross cutting, such as session and cookie management, authentication, etc. Some web frameworks make heavy use of middleware, such as Web::Simple, while Catalyst tends to mix and match between middleware and pre-existing Catalyst specific components. For example, Catalyst has its own mature session and authentication components, so we tend to use that rather than the Plack middleware (although over time I'd personally like to move towards using more middleware).
Template Toolkit (TT) is a templating system which is a common choice for a View layer in Catalyst. It allows you a more cleanly expressive approach to the concern of how your web pages look. Quite often you will use a Javascript framework, such as Dojo, Jquery or Angular.js to name a few of the ones I am personally familiar with. Javascript will be integrated into the View (TT). Catalyst, unlike some web frameworks, doesn't offer a lot of Javascript code generation tools since most Perl programmers prefer a more hands on approach and write their Javascript manually. Catalyst offers some tools for interacting with a Javascript application, such as support for JSON. So using Javascript with Catalyst is totally fine, just as I said compared to some frameworks you might find yourself needing to write a bit more manual code. As I said, Perl programmers tend to like to be 'close to the metal' so that is reflected in how Catalyst works.
I recommend you look at a few Catalyst applications on Github and review the tutorial if you can.
FastCGI is great, and my first choice for production systems. Plack implements PSGI and offers you a way to integrate a server such as FastCGI with your Catalyst web application. It also lets you 'glue' that same application to a different server. For example, many people use Starman as a server for development be cause its very easy to setup, but use something else in production (although Starman if run behind a proxy can be solid in production as well and some people choose that setup).
[client web browser] <--> [Apache <--> FastCGI] <--> [Plack FastCGI Handler <--> Catalyst <--> DBIx::Class <--> Database]
^^ is one example stack.
Here's a great blog of someone that started with Catalyst from the start and he did his best to record the journey. Maybe it will help you.
http://blogs.perl.org/users/j0e/
Also, I recommend reading the current and past Advent Calendars:
http://www.catalystframework.org/calendar/
You are welcome!
Best of luck! --jnap
歡迎指導(dǎo)! |
|