惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

博客园 - Vince

在ubuntu server上安装沸腾时刻环境 ubuntu中管理用户和用户组 ubuntu14.04设置静态ip ssh 返回错误 Too many authentic authentication failures for root 的时候检查 ssh 配置 ubuntu安装 laravel 过程中出现: mcrypt php extension required 的问题 | 以及composer相关问题 | Nginx安装 mongo里面根据对象字段的ID查询 db.Photo.find({'owner.$id':ObjectId('xxxx')}) , 并且使用forEach循环修改查询的数据 绝对居中对齐的好办法 blur效果,模糊效果css vitualbox 主机与虚拟机能相互访问的设置 mongo对象var_dump的时候无法显示更多数据的处理办法 mongodb lock 出毛病时解决方法 ag使用需要注意的问题 twig用法 imagick用法! Symfony中Doctrine对应的Mongodb数据类型 data type ubuntu 下配置 开发环境 nodejs mongodb 查询要看的文章 highcharts多个Y轴 IE=edge 让浏览器使用最新的渲染模式
symfon2 配置文件使用 + HttpRequest使用 + Global多语言解决方案
Vince · 2014-03-08 · via 博客园 - Vince

1. 在 app/conig中建立一个自命名的文件: abc.yml

2. 在 app/config/config.yml中导入abc.yml

文件头部:

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: abc.yml }

3. 在abc.yml中定义变量:

parameters:
myname: wangyingxi

4. 在代码中便可以使用了:

某action中:

$key = $this->container->getParameter('myname');
return new Response($key);

app.php是程序入口!

$request = Request::createFromGlobals()

$request=$this->getRequest();

$host = $request->getHost();

获取传参:

GET的参数:$request->query->get('aparam')

POST的参数:$request->request->get('bar', 'default value if bar does not exist');

HttpFundation里面的内容具体查看:

http://symfony.com/doc/current/book/http_fundamentals.html

多语言版本实现思路:

1. 在Symfony的route.yml配置

gy_mall_t1:
pattern: /t1
host: www.a.com
defaults: { _controller: GyMallBundle:Default:t1, _locale: global }

gy_mall_t2:
pattern: /t1
host: www.a.cn
defaults: { _controller: GyMallBundle:Default:t1, _locale: cn }

- 分类域名

- 分别传参(locale值)

2. Action部分可以接受到参数

public function t1Action() {

  echo 'current locale is : ' . $this->get('translator')->getLocale();

  // $this->get('translator')->setLocale('fr');

  exit;

}

3. 在/web/.htaccess中添加:

RewriteCond %{HTTP_HOST} ^a\.com
RewriteRule ^(.*)$ http://www.a.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^a\.cn
RewriteRule ^(.*)$ http://www.a.cn/$1 [R=301,L]

如果修改了.htaccess却无效,可以清空浏览器cookie再试试

清空cache,重启apache2

http://segmentfault.com/q/1010000000212748

http://stackoverflow.com/questions/11412476/how-to-translate-language-in-symfony-2-according-to-accept-language-header

http://symfony.com/doc/current/book/translation.html#book-translation-locale-url

(暂无用到下面这篇文章)

http://symfony.com/doc/current/cookbook/session/locale_sticky_session.html