I'm new to Symfony2, even though I knew symfony 1.4.
In my new project, I need a way to be able to load data from various text files (csv, xml, other), from various locations, in the most generic way possible, i.e. adding a new file to be checked should only require some configuration.
What's the symfon-iest way of doing that ?
Whilst I don't know of the implementation details for Symfony specifically; Gaufrette is a good PHP5 file system layer abstraction layer and they provide a Symfony bundle so it should be easy to get up and running. There are also details on getting it going on Symfony 2 in the read me documentation (scroll down).
You can easily add your own drivers for other file systems such as S3 (already implemented in base package).
Related
I'm trying to access the controller from another CodeIgniter.
I have a CodeIgniter 3.0.4 that containing:
Application
codeigniter2
css
js
...
so I have already tried $this->load->library('../controllers/home'); ,
but it shows me the Unable to load the requested class: Home
And I'm trying to login to both at the same time so I need to access each Session
I would strongly suggest that you simply either import the required library or combine both apps into the latest CI 3.1 as there have been several security fixes plus many more bug fixes. Upgrading from 2.x to 3.x is usually a very simple task.
However, you will not be able to use the CI loader to load a controller or library outside the normal directories, and you will not be able to share sessions across them either, as both sessions will have a different format for their session tables.
At a push, you might be able to create a bridge library, that includes the files you want, from the older CI version, but to be honest, unless the libraries you are connecting to are completely empty of any CI references, more like functional helpers rather than libraries, it just is not going to work, or would take far more work to achieve that it would to just upgrade and combine your old system. The advantages of doing that far outweigh the problems you are going to face with a bridging mechanism.
Sorry if that is not a lot of help, but in short, combine them into one app and upgrade to the latest version ASAP.
Best wishes,
Paul.
What is the best symfony file system abstract layer ?
i need to set up a file system at my symfony project, something similar to dropbox.
i dont know where the files/medias are going to be stored or how, so thats why i need that abstract layer, to set it up and dont bother about updateing the files location.
what i need to do:
-adding folders/files
-moveing folder/files to another lcoation
-delating folder/files
-download folder/files
-upload folder/files
-editing folder/files
-editing name of folder/files
do you know any good bundles for it ? any good solutioins for symfony 2 ?
and please tell my why can this solution be good for my ?
The currently available options seem to be:
1) Gaufrette
In order to transfer something you need to put it in memory first. This is a problem when you have to deal with huge files. Gaufrette has filesystem abstraction layer, but makes it impossible to move objects between filesystems. Some essential features are also missing, for example - removing a directory.
Feels more like a key-value storage emulator with different adapters.
2) Filicious
On paper seem promising, but in fact its not. The documentation is all wrong. It mentions namespaces that does not exist and classes that are not to be found. Most of the stuff around Filicious currently don't seem to be implemented. The only working adapter as of now is the Local one. You can track the progress on their website.
3) Flysystem
Looks better than the above mentioned. Has stream support. They also have this MountManager, which you can use for transferring files between different filesystems.
In summary, my choice would be Flysystem. You should better check it yourself if it will fit your requirements.
https://github.com/KnpLabs/KnpGaufretteBundle
Certainly the most in-depth implementation, it includes dropbox.
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.
As our company starts using Zend Framework as the base framework for most of our projects, we want to share some common elements across all our projects. I talk about things like:
An implementation of a model (based on doctrine2)
RBAC for the model, including user, group, role models
A xml-based templating engine for ajax backend interfaces
(you name it) ...
Basically, all things to put "zend on rails" and get going. What is the best way to package these components? I see two possibilities:
As modules
We include the necessary functions as separate modules into the modules folder.
Pro:
We can set routes and execute code, which is good for many modules (imaginary example: a paypal module needs some kind of callback url. If our module can set it up on its own, no configuration from the "project developer" is needed).
We can provide real functionality (like the user administration) out of the box
We have a bootstrap to set up autoloading and doctrine etc.
Con:
Bad place? Interferes with the users project
A little harder to share between projects (git submodules instead of classpath)
In the library folder
We put it in the library folder and point the classpath to it.
Pro:
Clean solution
Sharing across projects
Con:
Bootstrap has to be explicitly called
No direct routing or actions - everything has to be proxied through the concrete project
So, how do you solve this? Where do you put your reusable, general purpose stuff in zf?
I think you should use both approaches.
When developing "library-like" code, as in kind of "infrastructure" classes and other things that are reusable (like ZF's own components, Doctrine 2's components etc.), you can put them into the library directory. (or its own entirely separate project)
When developing actual ZF modules (like an auth module for example), then format the code around the ZF module structure.
I think by using this kind of approach you get all the benfits you listed, and pretty much none of the cons :)
As one additional idea, if you develop your architecture parts as "services", you could even keep them running as their own web service endpoints.
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