Beanstalkd in Symfony 2 - php

I am in the process of integrating some sort of background service executor. I am thinking to use Beanstalkd for it. I Googled it everywhere but I could not find a decent bundle to do the job with nice documentation. Few I found were
LeezyPheanstalkBundle
drymek/pheanstalk-bundle
But these bundles do not describe everything from start to end like this one from Laravel. Like listening for the job, sending arguments and so forth.
Is there any bundle for this or perhaps documentation? I found one nice one for Laravel with proper documentation and everything.
So, I am thinking if I chose to Laravel container for this job are there any tutorials regarding how to use Symfony bundles in Laravel. I found many for using Symfony bundles in Laravel but not the vice versa.
Can someone please give me any insight in this matter.

Working with Beanstalkd is framework agnostic. You should be better and more easy for anyone if you would learn Pheanstalkd library. You can install quickly with Composer.
Working with Beanstalkd is so simple that the two examples from the linked page covers most of the parts, the other more advanced stuff is also easy and at hand with a couple of function calls. You need to be clear with the procotol

Related

Routing in PHP, and how to set it up

I've recently started work at a new company, and was initially assigned to help the web development team.
To my horror, their template application they use to set up every single one of the projects they do, is completely procedural.
I am very eager to swap it over to OOP, but before I do that I need to actually understand how to create a project.
The initial work is there - there's an index.php that swallows all calls made to the site/web application.
What I need is a tutorial on how to set up proper routing so that I can look at a URL and go "call this function in this controller" instead of including a bunch of PHP files to get the job done.
Could someone please point me in the right direction?
I was in the same situation and this course helps me a lot to learn more about MVC and Routing in PHP. As #Armin said you can use Slim Framework or phroute .In the other hand, you can use Laravel framework to take care not only routing but also all the other challenges as a PHP developer you might have in the future
It sounds like they don't use any well known framework. They probably also don't want to use one. I think the best solution in this case would be some routing library. You could use the Slim Framework. You will understand everything you need to understand in about 30 minutes. It's very easy to setup and easy to extend.
You should not try to write your own routing library, it'll become quickly a quite complex thing. You will just reinvent the wheel and loose time.
I also would recommend the Slim Framework. I've spent way too much time trying to roll my own framework with routing but the maintenance and updating on my own framework got it the way of actual projects.
Slim is extremely easy to understand and offers a lot of flexibility to mold your own type of application. Between the routing, middleware, containers, and using the Eloquent DB ORM it has plenty to offer.
As others mentioned before, don't reinvent the wheel. There are plenty of tools out there you can lean on that allows you to focus on the actual project.
I think that Create your own PHP Framework from Symfony documentation is the thing you are looking for. You shouldn't be worried about the title, it's not only about creating frameworks. It shows you how to start using Symfony components in plain PHP application and eventually create your own framework.
But creating framework part is not the most important one. Understanding how to use object-oriented components in your code is the key part.
Of course, one of the components is routing. It's use is described in first chapters: Introduction, The HttpFoundation Component, The Front Controller, The Routing Component, Templating (don't skip this one!). But I recommend continuing to the end, it's easy to read and very interesting article. Even if you don't want to use Symfony (or it's components) this article will help you understand how to use any modern PHP components.

Laravel is great but... where's the consideration for HATEOAS?

I've begun using Laravel 5.4 instead of Spring boot for a web application I'm currently developing and it's going great. I'm really enjoying the lack of verbose boilerplate that Java/Spring has. However, one of my requirements is that the API must be HATEOAS.
I've literally searched for days for research material and only come up with a couple of not-so-popular libraries. Is there a reason for this complete lack of exposure of HATEOAS for Laravel when for other web application frameworks there's at least some material?
Edit: I'm not trying to talk down on Laravel, I just want to know why there's no resource on HATEOAS implementations with Laravel as the framework, or if I've missed it, where I can read up on some HATEOAS Laravel goodness.
Since Laravel uses the Symfony underneath, I think this repo would work: https://github.com/willdurand/Hateoas

How to upgrade symfony from 1.4 to 2.1? [duplicate]

I've got a huge site that has been written (in a very bad way) in symfony 1.4
now, I've been asked to make some substantial changes to the navigation flow, add some features and so on..
considering the effort, I was wondering if it would be better to take the radical decision to port the entire website to symfony 2.0, but I'm not sure how hard that it could be.
Has anybody ever done this before?
Do you have any suggestion to make for patterns to follow, or tutorials or doc or whatever?
You may wrap your legacy project in a brand new sf2 project, by using this bundle. This way, you'll be able to migrate your project one piece at a time, and new functionalities may be developed with sf2 as soon as you get the wrapper to work.
You may be interested by this post about migrating
Here's how I would go about it:
You need to learn and study some things first:
HTTP fundamentals
PHP namespaces, which are heavily used
Symfony2 documentation
Symfony2 documentation
Symfony2 documentation
PHPUnit documentation
Then when you get the hang of Symfony2, you need to find out what to reuse from your old project:
Models, business logic?
Did you use Doctrine in symfony? If yes, look at how to port your entities to Doctrine2, and learn about the differences. If you used Propel, I would look at switching to Doctrine2 and not use the PropelBundle, atleast until you get used to Symfony2. You can find better documentation and sample code out there for Doctrine2.
You also need to convert your old helpers classes to Symfony2 services.
Views?
Symfony2 uses Twig as templating engine, but you could go with pure PHP.
Controllers?
This should feel somewhat similar to symfony. The flow of Symfony2 matches the HTTP flow, meaning you get a Request object and must reurn a Response object.
It really depends on how well structured our old project is. Symfony2 is an entirely different beast than 1.0-1.4. I would probably not call it a port, but a rewrite - however, if your old project is well structured you could probably reuse quite a bit.
Without actually seeing your code, it's impossible to give a good answer on how hard it would be. It's very much doable, but there is no easy route. Symfony2 is, IMHO, the way of the future for PHP projects and in the end you will get a project that is much easier to maintain and support.

Porting a website from Symfony 1.4 to 2.0

I've got a huge site that has been written (in a very bad way) in symfony 1.4
now, I've been asked to make some substantial changes to the navigation flow, add some features and so on..
considering the effort, I was wondering if it would be better to take the radical decision to port the entire website to symfony 2.0, but I'm not sure how hard that it could be.
Has anybody ever done this before?
Do you have any suggestion to make for patterns to follow, or tutorials or doc or whatever?
You may wrap your legacy project in a brand new sf2 project, by using this bundle. This way, you'll be able to migrate your project one piece at a time, and new functionalities may be developed with sf2 as soon as you get the wrapper to work.
You may be interested by this post about migrating
Here's how I would go about it:
You need to learn and study some things first:
HTTP fundamentals
PHP namespaces, which are heavily used
Symfony2 documentation
Symfony2 documentation
Symfony2 documentation
PHPUnit documentation
Then when you get the hang of Symfony2, you need to find out what to reuse from your old project:
Models, business logic?
Did you use Doctrine in symfony? If yes, look at how to port your entities to Doctrine2, and learn about the differences. If you used Propel, I would look at switching to Doctrine2 and not use the PropelBundle, atleast until you get used to Symfony2. You can find better documentation and sample code out there for Doctrine2.
You also need to convert your old helpers classes to Symfony2 services.
Views?
Symfony2 uses Twig as templating engine, but you could go with pure PHP.
Controllers?
This should feel somewhat similar to symfony. The flow of Symfony2 matches the HTTP flow, meaning you get a Request object and must reurn a Response object.
It really depends on how well structured our old project is. Symfony2 is an entirely different beast than 1.0-1.4. I would probably not call it a port, but a rewrite - however, if your old project is well structured you could probably reuse quite a bit.
Without actually seeing your code, it's impossible to give a good answer on how hard it would be. It's very much doable, but there is no easy route. Symfony2 is, IMHO, the way of the future for PHP projects and in the end you will get a project that is much easier to maintain and support.

Zend Framework 2 + Doctrine 2 skeleton app

For some time now I'm playing with ZF2 and Doctrine 2 and I find them great.
I don't have much experience with either of them, but I've been looking into multiple tutorials and sample apps. They gave me some idea about the libraries, but I'm not feeling comfortable with things like DQL and flushing the EM in the controller. I realize ZF2 is still a beta, but I hope there is some piece of code that shows a scalable structure that can be the skeleton of a real life app.
Please share your experience and if possible provide sample source code.
Regards
Valentin
http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/ - nice tutorial all what you need to setup ZF2-D2
The skeleton is a skeleton of a real life app, that's what it is there for. If you want to hook up zf2 with doctrine, just install the DoctrineModule, and DoctrineORMModule (or ODM if that is what you want.)
DQL shouldn't really be in your controller, put it in a repository instead.
The EM can be flushed in your controller, but it can sometimes be better to set up an event listener, and then flush the EM once at the end of each request.

Categories