Comments (6)
I think you can do such check in Yaf_Plugin::dispatchLoopStartup, then twist the Yaf_Response into any form you deteced in DispatchLoopShutdown
from yaf.
That would mean I would had the same data in all forms. I want to fetch the data depending on the output type. It's not just a case of "formatting" the output.
from yaf.
@guilhermeaiolfi i think that you need a custom Route.
A custom Route can match a request against http_accept or by url 'extension' ex product/1.xml, product/1.json etc.
So according to request you can tel the Route execute the action you want.
But in most cases a browser sends an http_accept like text/html,application/xhtml+xml,application/xml;
so a good solution for browser based applications, not REST API, it is a good practice to play with url 'extension'
from yaf.
@guilhermeaiolfi Another solution:
Make different views for HTML/XML/JSON into different view directories, you could keep default view path as APPLICATION_PATH/views
, and create APPLICATION_PATH/views.json/
, APPLICATION_PATH/views.xml/
or APPLICATION_PATH/views.mobile/
. Then let Plugin to setScriptPath for view on different condition.
Hope it could answer your question.
from yaf.
@zh-ang: That's the closest I was thinking of. But that would require a lot more files than needed in my case. That's why I was thinking in different method for each output type and not different view/class/files. But I'm confident that it'll be possible and that it'll not be difficult. Thanks everyone for the suggestions.
from yaf.
Wouldn't it be nice to support this concept in the Yaf core? In a world of backbone, ember, angularjs, knockout and so many others. The server side of things needs to delivery all kinds of data depending on who is requesting. I think that's where web developing is heading.
My case is that my ERP request data using SOAP, I'm creating a web admin panel that uses a REST API, and the regular user/visitor uses plain HTML.
from yaf.
Related Issues (20)
- 关于 route_static 解析问题 HOT 2
- Request::setControllerName 第二个参数format==false时 设置失败 HOT 1
- Yaf_Registry::set 的第二个参数为什么注释为 string 类型 HOT 1
- yaf model 的问题 HOT 2
- 开启公用类库后,无法使用composer HOT 2
- 偶发性问题Uncaught Error: Call to a member function run() on bool in ....../public/index.php HOT 1
- 希望鸟哥能增加一个配置用于控制是否开启默认路由. HOT 1
- yaf routing with namespace is on option HOT 4
- Fatal error: Class 'Yaf' not found HOT 2
- PHP8.2下 安装yaf-3.3.5报错 HOT 5
- Yaf_Config_Ini 造成 Too many open files 问题 HOT 3
- 使用了__get魔术方法后,当action不存在的时候,php进程会被直接终止,无法捕获错误。 HOT 4
- 支持phpstorm的代码查找
- v3.3.5 Yaf_View_Simple __isset bug
- fpm进程中存在多个application.ini文件句柄 HOT 3
- Error: Failed opening controller script
- PHP8.3 install yaf-3.3.5、yaf-3.3.4 extenstion error:make: *** [Makefile:209: yaf.lo] Error 1 HOT 2
- README.md contains outdated references to Travis CI service
- php-ext
- 使用 Yaf_Request_Http 对象的 getRequest(), getPost(), getQuery() 3个方法获取单个参数时候会导致程序中断
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaf.