How to route symfony2 404 to symfony1 legacy app - php

I'm migrating a symfony1.4 application to symfony 2.5, and we need to run both applications simultaneously seamlessly to the end user.
The idea is to land on sf2 app and if a certain route does not exist, then route (fall back) to the sf1 app.
The challenge here is to use the same domain.
For instance:
www.mydomain.com/ > lands on sf2 home page.
www.mydomain.com/contact-us > routes to an existing sf2 controller/view
www.mydomain.com/some-form > does not exists in sf2 app, then it redirects/forwards to the legacy sf1.4 app keeping the same url (user doesn't need to notice the forwarding)
Any ideas on how to best approach this?
Cheers,
Fabian

I think this wrapper bundle was designed for your purpose:
https://github.com/theodo/TheodoEvolutionLegacyWrapperBundle
This bundle allows you to call the legacy framework from Symfony2. Tested and works for legacy app made with symfony 1.4.

Related

How to change a symfony project from mvc to client-server architecture?

I recently started learning PHP and Symfony 4 and I developed an app. Now my next task is to change the architecture of the project, from MVC to client-server. More exactly, I need to have my templates and controllers in an application and the business logic in another application. Any ideas how I can do this? I can't even figure out how to run 2 different symfony projects simultaneously.
A client-server application is an application base on a communication model call client-server: wiki
MVC is a way to develop and structure application: wiki
But i understand your needs. You want to keep a symfony app but you also want to put all the logic view and front end features into a separate app (like React or Vue)
Your Symfony App will still use MVC pattern, just you'll replace what the controller give to the view.
The best way is to turn the Symfony App into API with normalize view data like JSON or XML. Those data will feed your front app.
To achieve this you can use this bundle, which turn your model layers into API: API Platform

Symfony 2 - Portal features (out of the box)

I want to start developping an online portal with Symfony 2 for a specific business case. User can register, save some data and schedule some executions.
But before I will start to invent all features by myself I tought I would ask the community if there is a starter-package Symfony 2 with some core functionalities (MVC) for an simple online portal:
Registration
Login (BN/PW, FB-Login, ...)
Login reset
User management for admins
Maybe with some optional functionalities for users like:
Profil edit
Avatar upload
PW change
If there is a starter-package I could save a lot of time and start developing my business logic faster.
Thanks,
rjgamer
There is no 'out-of-box' complete Symfony2 application which run immediatly after installation.
BUT
Symfony2 has a concept for this way. The concept call 'Bundle'.
Bundle is used for speedly building application with Symfony2 Framework.
With lot of bundle in application symfony2, you can easily and more faster construct an application. More configuration and parameters but less implementation of code.
The most popular example of this concept and your requirements is the bundle FOSUserBundle which help you to install a full system of user for your application without implementing yourself lot of basics concepts of management users.
You must search bundle for which of your requirements.
You find for almost anytime a bundle for your requirements.
Perhaps search a github project which contain all of this popular bundle in symfony application.
Welcome to big world of Symfony and try to find your favorite bundle !

Prevent Apigility from conflicting with routes from existing Zend Framework 2 projects

I have an existing Zend Framework 2 project. Now I've been experimenting and considering rebuilding the front end to be entirely AngularJS, as opposed to the now with Zend Framework 2 MvC coupled layouts and views. But for that reason, the models and controller with their respective routes exist and they use services that have a lot of business logic.
If I were to add an API to this existing project through Apigility, say, for external third parties to be able to access account information, how am I supposed to do that without interfering with my current controller routes?
Apigility Admin UI automaticly creates routes appending the base url (www.domain.com/[api url]). This does not directly conflict when I have an AccountController with /account routes and an API route that uses /accounts/[:accountId] but mistakes are bound to happen.
I should use a url like api.domain.com, however Apigility Admin UI adds the routes automaticly and has, as far as I have seen, no option to create a subdomain route through subdomain 'api'. Of course I could modify the automaticly generated routes every time I make changes through Admin UI but that seems like a hassle and prone to error.
While spreading my question around for an answer, someone on the #apigility IRC channel was friendly enough to give me an answer.
I was overthinking this, as dualmon mentioned in the comments. I had thought Apigilty Admin UI was a tool for managing the whole API. nuxwin^ on IRC told me that while Apigility Admin UI does automate routes for you which can be configured with a base url, it's still only meant for development time. It would mean if I were to route my subdomain to a module I could do that after developing the API.
Simple solution, I just had been overthinking that tool demanded me to follow a certain path.

Symfony2 Web Service

I'm currently designing a new web application based on Symfony Framework that will serve both web and mobile accesses. For illustration purposes I will use the default AcmeDemoBundle from Symfony`s framework to elaborate my question.
So, DemoBundle gives me the following route:
/hello/{name}
So far so good. Now, I want to implement an API in this project that will serve mobile apps, so the route for the same controller as the route above whould be, for instance:
/api/v1/hello/{name}
My doubt is: what's the best way of doing that without replicating code? I intend to use the FOSRestBundle for the API and I know that he handles rendering HTML views to, but I'd like to separate the API routes from the web as I put before. Maybe should I create a new bundle for the API?
Create a bundle for the API is not a good practice for the simple reason that you can't easily re-use the bundle in an other project.
For example, you create PostBundle and his API bundle, APIPostBundle for your A project.
If you want to use that bundle for a B project, you need PostBundle and APIPostBundle. You created dependency between two bundles and it's a bad practice (Component-Based Development).
So, you have to generate an independency bundle with a strength architecture who can allow you less modification if you have to.
Use a service for the logical instructions. Then, the controller/APIController can manage the route and will call the service methods. By that way, you can just modify the service without editing the controllers.
So, your architecture looks like that:
PostBundle
Controller
- PostController
- APIPostController
Service
- PostService
- PostServiceInterface

Symfony routes in App Engine

Although we had some difficulties, we finally achieved to make our Symfony 1.4 application work fine in App Engine.
However, we are experiencing a problem related to the routes in Symfony.
From App Engine SDK (localhost) everything works perfect. If we access the URL:
http://localhost:9080/user/create
The parameters "user" and "create" are automatically detected by symfony as the "module" and "action" variables.
But when the application is deployed in App Engine, the same route /user/create does not work. Symfony shows an error message indicating that both the module and action parameters are empty.
Any idea of why these two environments have different behavior or how could it be fixed to get it work in the same way as in App Engine?

Categories