Symfony solr bundle 2.8 + - php

I started to get data from solr with curl but this is not the symfony way and I want to change that before is "to late".
There is most popular nelmio solr bundle (this is info I found from googling) i also found some other bundles, but wanted to pleased you to help me in choosing nelmio or suggest some better bundle that is fully support also and symfony 3.0

First off: Using NelmioSolarBundle and floriansemm/SolrBundle have very different use cases.
NelmioSolrBundle is just a symfony integration of the solarium library, which is nothing more than a wrapper around those direct curl requests.
The SolrBundle by floriansemm integrates solr deeper into the framework by making annotations available to declare which entity fields i.e. are stored or indexed in solr (done via dynamic fields). I found the options using normal schema.xml definitions are way more powerful since not everything is available there.
In my current project i first tried using SolrBundle but ran into some limitations which led me to switch to NelmioSolariumBundle. (so my solr config and schema are maintained directly in the solr and not through annotations and so on)
Once you get used to the solarium library (http://www.solarium-project.org/) the nelmio bundle works fine but in the end it's nothing more than a fancy way of executing those curl requests.
So if your implementation works, keep using it.
Hope this helps.

Related

Linking Symfony2 with Solr

It's clear, how to plug Solr in Symfony2 framework? I found some resources out there but they're totally unclear or incomplete. There supposed to be a Symfony2 bundle named NelmioSolariumBundle but can't get it well, poor documentation.
If you have done this operation, please give us the How-to answer in few Get-started steps, or any good straightforward documentation/tutorial will be appreciated.
Solr can be easily connected through it's REST interface, so if you have an easy use case, you might only have to use a PHP library that can talk to solr.
I use this library hosted on google code. Also I'm working on a solr bundle wich provides a convenient way of indexing doctrine entities, it can be found here but it's also work in progress and almost no documentation....
The functionality so far is limited to index entities by cli and doing standard search. I'm currently using it in another bundle to index a geo database and providing an autocomplete form type for locations, you could check out the code for figure out the usage here...
If my bundle is not of any help, you might get an idea of how to create your own implementation.

Which MongoDB library to use for a stand-alone PHP project with Symfony?

I am leading a new project where we're convinced that MongoDB is the right choice for database. We have decided that the architecture would be SOA, so the web part will be developed using Symfony and the service part will be developed using light-weight REST framework Tonic.
Now, in the service part, we'll be communicating with MongoDB and for that, we have looked into a number of available MongoDB libraries: Doctrine MongoDB ODM, Mondango, ActiveMongo, MongoRecord, etc. However, we are not sure which one to pick.
I was wondering if anyone can share their experience with these libraries so that we can make the right choice. Here are some of the properties we consider the library should have:
Plain PHP classes for defining documents (instead of array/config files)
Support for references
Efficiency in operations
Easy to understand API
Looking forward to your views!
Personally I would go with Doctrine2 ODM. Seen as you have already decided on Symfony as your framework for doing the heavy lifting the pair are well aligned as far as I understand. You should be able to use this https://github.com/doctrine/DoctrineMongoDBBundle to integrate the two pretty quickly.
The doctrine setup ticks all the boxes you've set for your project goals and is fairly easy to get working with. Most importantly, it's an active project so bug fixes/features/documentation updates happen fairly regularly.
We use a similar setup, except zend framework instead of Symfony, and we're very happy with the results.
Hope this helps.

Symfony project using CURL - building project with API

I have never used a PHP framework before and am considering using Symfony for my next one. However, I have already built an API which has all my main classes. I will therefore connect to this API using CURL. Can anyone advise on where to start with such a project. I am working through a Symfony tutorial but none of it seems to apply to what I need to do as I do not need to create database connections or classes as I will be building this project on my existing API.
If you don't need a lot of what you see in the Symfony tutorials you might be able to get away with Silex. Silex is a mini-framework with alot of the core aspects of Symfony, but without the extra stuff.
http://silex.sensiolabs.org/

Using Symfony doctrine models in a REST framework

I have a web application which has been developed with symfony 1.4. I have a pretty large code base (and growing). Circa 80,000 lines of code (actions, forms, models, templates etc.)
I'm using the default doctrine version which ships with symfony 1.4.
I've just started developing a mobile version using Sencha touch. I don't wish to use symfony for the REST web services because:
REST services in Symfony 1.4 is not great. For example, If i want a PUT request I have to pass a 'sf_method' parameter specifiying that the request method is PUT. This isn't true REST and it's not ideal for Sencha touch.
I don't need all of the unnecessary symfony functionality(for example the plugins that are autoloaded in the ProjectConfiguration file, the form framework etc.) that you'd use to develop a standard web app. All I need is to define my REST routes and return the specified JSON (as everything that needs to be returned for Sencha touch will be JSON)
I want to keep my mobile app as bloated-free, efficient and quick as possible. And unfortunately for this task, Symfony 1.4 would not be the best choice for using as the backend architecture for my mobile app. If I had chosen symfony2 (it was in it's beta phase, alas) it would be a different story as symfony2 supports true REST functionality. What I do need, however, is the ability to use my current doctrine models (I have circa 90 models) in a chosen REST framework.
Basically, in a nutshell what I need is as simple as this:
Call a rest route->Query my doctrine models->return the JSON without using symfony.
So my question, what would be your advice? I don't want this to be a question of which is the best PHP rest framework, however, what I would like to know is what would be a good REST framework which i can develop efficiently and quickly REST service, make use of my doctrine models and is easily extendable.
Here at my employer, I've created a rather big application with a ExtJS frontend, and Symfony 1.4 backend. And two be honest, I don't feel limited by Symfony 1.4 in any way?
First of: I created my own base controller class (which extends sfActions). This controller can handle (render) different types of data. It has generic handling for Doctrine_Query, Doctrine_Collection, Doctrine_Model and array types.
Also the plugins make me help organize the code, and in some cases plugins are shared between differend projects, so that's also a big plus.
And the extra functionality like forms: it's only prepared for you in the autoloader, you don't have to use it. And I don't think it causes any real performance issues (at least not for me). But I like to use the extra sfValidator framework, to make sure data are correct.
The only real "problem" is indeed the HTTP REST-ful commands, especially PUT and DELETE. I just worked around this problem by generating a controller for each 'manageable' model, and implement specific get, list, create, update and delete actions. So when I would like to manage an Object, I call the objects controller, which has executeCreate, executeUpdate and executeDelete actions.
The reason I read, was that Symfony didn't and couldn't implement this feature because PHP has really bad support this. I don't know if this is true, but if this is your only 'real' issue, you could try to fix this in the Symfony core.
So my advice:
If the raw performance is your problem: try profiling your code, install a opcode (APC) cache, and profile your code (yes, that's double).
If the HTTP PUT command is your problem: I would either work around this (that's the way I solved it), or try to fix it in the core.

Symfony2 standalone form component - setting up a form

I'm trying to implement Symfony2 form builder component as a standalone. The documentation
doesn't really talk about this though, just in relation to using the whole framework.
The standalone is on Github but has no docs.
Ive searched around and seen a few people ask this question but none seems to have any answers.
All I need is a basic guide on how to setup a form , build it, then view it.
Anyone?
Edit: My first response below is now obsolete (and the link does not work anymore). Please refer to
https://github.com/webmozart/standalone-forms for a state-of-the-art solution.
Previous (now obsolete) answer:
I've tried hard and managed to display a form (using PHP engine, not Twig).
Indeed you need a few components: Form, but also ClassLoader, EventDispatcher, Templating (for rendering) and Translation (for rendering labels). You will also need some resources from the FrameworkBundle bundle (mainly templates).
More info on this:
http://forum.symfony-project.org/viewtopic.php?f=23&t=36412
And my mini-tutorial:
http://n.clavaud.free.fr/blog/index.php?article31/symfony2-standalone-form-component-tutorial
First, copy Form Component to your project to directory which contains third-party libraries (not only Symfony components, but also ORM or whatever), let's say lib/, so it's in <project_path>/lib/Symfony/Component/Forms.
Then you have to auoload it - either manually or using any PSR-0 compatible class loader i.e. SplClassLoader or Symfony's UniversalClassLoader (there is chapter in docs and in quick tour about this). Example:
$loader = new UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__.'/lib');
$loader->register();
Using Form Component isn't in fact strongly documented, but in Symfony Book there are few examples how to use Form classes about this component, so I guess you'll have to dive into sources, beginning with Form class (maybe later you'll give some feedback about experiences somewhere in the Web?).
Since Symfony 2.1, the form component has been using composer.
You can locate the composer.json file inside the repository. It contains a dependency map that can be used to get the dependencies installed.
You can do so by simply running composer install from inside your console.
P.S I know this thread is old. The information I'm contributing apply to any new users that may need it.
First of all not with Symfony2. But creating form with Aura.Input and some view helpers of Aura.View makes it easy to bring Standalone Forms and Validation.
If you are interested you can read it over http://harikt.com/phpform/ , and source is in github.
/*
* This file is part of the Symfony package.....
what i understand from that line is that the file is a PART of the framework, can't be removed, can't be ripped, and it won't function if you rip it off the package because it requires other related files in the framework
however, there is an option, and it is to investigate the files and see what functions they call and what variables they use ,redefine them, and use it as standalone IF the license allows you to

Categories