I'm new to Laravel and some MVC theory, so I have been doing some research as to the best way to use third-party scripts and applications within Laravel (this question, however, certainly applies to any MVC framework). Unfortunately, I have not found an answer to my question so I thought it would be helpful to myself and others to ask it here!
Basically, I have osTicket and I wish to use it in my Laravel setup. Since osTicket is it's own, third-party application, where is the best place to upload this within my Laravel installation? My initial thought is /public/, but the little documentation I read on /vendor/ makes me think it belongs there.
Would love best practice advice on where this should go...thank you!
Related
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.
Is it possible to use Laravel alongside another php application not built with a framework just for the login/authentication system?
Looking at other posts, I realize that's not the point of php frameworks, but my thought was for maximum security, using a framework would be best.
It's entirely feasible, yes. Especially if said application was properly classed and namespaced.
If it's not classed / namespaced, that rules out simply including it in Laravel. That'd likely be way more headache than it's worth.
In terms of security, there are a lot of routes you can go. In fact, there are authentication websites that take user information completely off of your hands. It may be worth looking into them.
The easiest solution would be to either find a class or library that is dedicated to authentication, and simply include it in your application (example here: http://ulogin.sourceforge.net/ or simply search for PHP Authentication Library). They're framework agnostic, and will be very simple to integrate into your project.
The bottom line is, you probably want something that's agnostic to frameworks / coding architectures. That'll be the easiest to integrate into a custom project.
The company i work for are looking to move their php web application over to a framework. I personally haven't had much experience with php frameworks at all, so i need to read up on them and learn which ones are best.
My question is, is there a quick way to migrate a standard php/css/html web application over to a framework without having to rewrite a lot of it?
If not, what are some good reputable companies that do this.
Thanks in advance.
No, there is no quick way to migrate the application. Start with a requirements review, you may find that a robust CMS or cart will provide a lot of the features you need.
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.
I'm developing Code Igniter as framwork and i want to switch to Symfony but the problem is that I don't even know if I have bad habits with MVC or Framwork in general.
I know it's a quite subjective question, but I thought it could be a good idea to ask people who has already practice with this framework.
So if you have some Do's and Dont's about framworks in general or more accurately about Symfony I would be grateful !
Timon.
The Documentation on the Symfony website is all you need - its very extensive and will help you learn the framework quickly and in depth
Check your applications before deployment with list on http://symfony-check.org/
These are some tips:
Don't modify css/javascript codes from the web directory, you
must edit them in your src bundles, then assets:install, and
assetic:dump.
Never try to mix PHP and twig codes
Never edit the framework bundles (the vendors folder)
Use fixtures for your tests.
Try to avoid dependencies between bundles. Every bundle should be
independent of the others.