symfony1

Web front end caching best practices for site?

元气小坏坏 提交于 2019-12-03 03:29:59
Summary As I'm looking on stackoverflow and around the net, I find that there is a general lack of good documentation on best practices for caching a high performance site that uses sessions. It would be helpful if we can share some ideas around some basic building blocks particularly around caching. For the purpose of this discussion, I'm avoiding memcache and focusing on the caching of static and pages that are fully generated. So to set up the scenario, imagine a web server (say nginx), reverse proxy (say varnish), app server (whatever), db server (say mysql). Anonymous Static items (gif

How to structure this Symfony web project?

你离开我真会死。 提交于 2019-12-03 03:26:17
I am new to Symfony and am not sure how to best structure my web project. The solution must accommodate 3 use cases: Public access to www.mydomain.com for general use Member only access to member.mydomain.com Administrator access to admin.mydomain.com All three virtual hosts point to the Symfony /web directory Questions: Is this 3 separate applications in my Symfony project (e.g. "frontend", "backend" and "admin" or "public", "member", "admin")? Is this a good approach if there is to be some duplicate code (e.g. generating a member list would be common across all 3 applications, but presented

Doctrine: Multiple (whereIn OR whereIn) query?

荒凉一梦 提交于 2019-12-03 03:17:31
I'm having trouble crafting a fairly simple query with Doctrine... I have two arrays ($countries, $cities) and I need to check whether database record values would match any inside either. I'm looking for something like: ->whereIn('country', 'city', $countries, $cities) ... with 'country' being a WHERE IN for $countries and 'city' being a WHERE IN for $city. I could separate the two out but the needed query has lots of other conditions so that's not possible. The resulting SQL I'm after would be: SELECT ... WHERE ... AND ... AND ... AND ('country' IN (1,2,3) OR 'city' IN (7,8,9)) AND ... AND .

Anchor in URL when using Symfony's redirect function

帅比萌擦擦* 提交于 2019-12-03 01:19:40
I'm using $this->redirect('route', array('id' => $id)); but I need to be able to put "#" anchor at the end but I can't find a way of doing that. Any ideas? The code $this->redirect('route', array('id' => $id)); returns /route/id/5 but I want to be able to create /route/id/5#anchor7 $this->redirect($this->generateUrl('route', array('id' => $id)) . '#anchor7'); UPDATE: In Symfony 3.2 you can do this: // generating a URL with a fragment (/settings#password) $this->redirectToRoute('user_settings', ['_fragment' => 'password']); See https://symfony.com/blog/new-in-symfony-3-2-routing-improvements

got a select that does 10 query in doctrine (Symfony)

ぃ、小莉子 提交于 2019-12-03 00:29:40
问题 I got a big query that execute 11 query, I didnt know where the problem is, but found the problem was in a select a did for geo loc, anyone has an idea how to correct that? It happens only when i use this query SfDoctrinePaginate Investigating further $q->select("a.longitude") create as much queries.. The problem: $q->select("a.longitude, a.latitude, (3959 * acos(cos(radians('".$lat."')) * cos(radians(latitude)) * cos(radians(longitude) - radians('".$long."')) + sin(radians('".$lat."')) * sin

what's the proper way to use Symfony's EventDispatcher component?

允我心安 提交于 2019-12-03 00:09:08
I'd like to promote loose coupling in my PHP code, by making certain classes observable. Symfony's EventDispatcher component looks promising, as does the SPL SplObserver / SplSubject pair of classes. What's the best way to do this? I can see a couple of different possibilities: (1) Inject an EventDispatcher instance into each observable class (keeping track of a global EventDispatcher instance): class Foo { public function __construct($dispatcher) { $this->dispatcher = $dispatcher; } public function bar() { $this->dispatcher->dispatch(...); } } (2) Have the observable class extend the

Breadcrumb navigation with Doctrine NestedSet

社会主义新天地 提交于 2019-12-02 22:22:21
问题 I have a model that implements NestedSet behaviour: Page: actAs: NestedSet: hasManyRoots: true rootColumnName: root_id columns: slug: string(255) name: string(255) Example fixtures: Page: NestedSet: true Page_1: slug: slug1 name: name1 Page_2: slug: slug2 name: name2 children: Page_3: slug: page3 name: name3 I am looking for the easiest way to implement breadcrumb navigation (trail). For example, for Page_3 navigation will look like this: <a href="page2">name2</a> > <a href="page2/page3>name3

Is Symfony a better choice than Zend for a web development shop (10+) because it is a full stack framework? [closed]

*爱你&永不变心* 提交于 2019-12-02 21:13:17
My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight. I'm afraid however that they are only looking at the technical advantages that a lightweight framework will have. In my opinion it is better to have a full-stack framework (and I am a proponent of Symfony) because It will also provide us with a standard way of working without writing new documentation. If we would like to use new features we

How to set different template layout for different modules in Symfony

谁都会走 提交于 2019-12-02 20:44:52
How to set different template layouts for different modules in Symfony? I have a banking application that consists of a login screen, and a member section. So when a user goes to my site he will be presented with a login screen. After login in he will be redirected to the member section that he can do his whatever banking needs. So, how to set different layouts for the login screen and the pages inside the member section? Symfony seems to use frontend/templates/layout.php as the template for ALL pages. Is it possible to define different layouts? Yes, you can define separate layouts per view

How to create a custom yaml config file in Symfony

守給你的承諾、 提交于 2019-12-02 20:37:36
What I want to do is quite simple: store data in a custom config file that I want to read later on. I created my file something.yml that I put in the global config directory. It looks like that: prod: test: ok dev: test: ko all: foo: bar john: doe Then I copied the config_handlers.yml and also put it in the config directory and added the following at the top of the file: config/something.yml: class: sfDefineEnvironmentConfigHandler param: prefix: something_ But if I'm calling sfConfig::get("something_foo"); I keep getting NULL . What did I do wrong? I just want to read values, so no need to