I've seen a lot of posts about switching from php to Django but none have covered this. I have a website that is built entirely in php (php 5, mysql, and apache2). This site is used only for collecting data from users. Now I need to make a second half of the site to display the data. This will be step 2 of 5 in the overall plan, and I'd rather not keep using php. I was wondering:
How hard would it be to run a Django server (hopefully on the same computer) that would serve data from the php based database?
Could python classes (inheriting from django.db.models.Model) be formed to get the data from the php database?
Could Django authentication be used with the preexisting users table?
Cheers.
Chris
Python and PHP can be run from the same server just fine. There may be performance issues on heavy loads when mixing mod_php with mod_pythong/mod_wsgi though.
Much of Django is based on its own ORM. So you would not be getting the full benefits of Django if you're serving data from a database built outside of its ORM unless you changed the schema to match directly. But to answer your questions:
The easiest way to do this would be to use django's auth system and then migrate your current users to django.
Related
im currently in the face of considering what to use for building a piece of software - The system needs to handle complexity like:
- User Management (ex: Trainer Login - Client login)
Different dashboards (Depending on user profile)
Workout Builder (Trainer must be able to create workout programs and send(email) and attach (Client can see workout program in system) the program to a client)
Diet Plans (much like the above)
Workout Library
Booking/Calendar (Client should be able to book a trainer)
Training Logs etc...
As you can see, there would be alot of relations/bindings etc, and personlization (Dashboards) etc... I think you get the idea :) - However, im a Frontend Developer, I do have php experience and mySQL (However a long time ago) - So the question is... Is this system possible to build completely with ex: Angular, Express, Mongo and Node - Or would I have to depend on a database system like mySQL and use ex: PHP for the system ?
Thx in advance for any answers :)
In my opinion, if your hands on experience with PHP and MySQL is good enough you should go ahead and deploy your application with PHP and MySQL with MongoDB as an additional database.
I understand that MEAN stack can power up your complete app, but the development time would be longer, and for what I have felt while using MongoDB over petabytes of data is that MongoDB is amazingly great for storing complex data in a flat architecture in massive size. But just like all databases, even MongoDB has certain constraints.
You should go ahead with MySQL for your usual Login credentials and minor activities, for storing Diet Plans, Workout Libraries use MongoDB. Because that gives you a flexibility of the varying document structure and high availability. Over the time you will find MongoDB easier to work upon than MySQL.
Using MEAN Stack is great. But, now I prefer to use a mixed architecture of MySQL, MongoDB, and PostGres. If you are going to use any framework it would probably have ACL in it or available as an add-on, and that could help you with building permissions and roles of users.
Also, if you are using MongoDB, make sure you code according to the engine MMAP or WiredTiger, I had to do a major recoding because of the storage engine changes. Just a heads up!
Yes, it is possible to build on pure JavaScript stack like MEAN: MongoDB, Angular, Express, Node.js
Everything that MySQL does, MongoDB can do also. The question is only in proper database design and performance for specific use cases.
I am currently developping my own CMS using PHP/SQL on the server side and Javascript on the client side.
A previous version of it was pure Javascript but I realised that this was making my website unaccessible to no-script users.
I therefore shifted my paradigm to a server building a basic version and javascript providing eyecandy options.
The data are in a SQL database accessed using PDO.
Some co-workers wanted to use my CMS but they are not used to MySQL and dont like to have to migrate their databases when migrating their website (which, for many reasons, can happen quite often).
I thought of using SQLite as the database would be a simple file that could be moved easiely. However SQLite is not available in our institution professional web pages service.
I understand that using a php based impementation would limit the capabilities of load balancing (which you have when physically separating the webserver and the database) but my database would stay very small and shouldn't cause performances issues.
Question:
Is there any php impementation of SQLite that would work even when sqlite and pdsqlite modules are not available ?
Is there any other solution to have PDO fallback to a basic file-based database that could be migrated easielly ?
Try the pdo odbc adapter often this can be used.
If sqllite is not available why not go back to flatfliles especially if the data amount is not to big write json files or xml files these can be queried quiet easily especially the json files further they are easily ported.
I am developing a new page and can not decide witch server technology I should use. I will try to describe as best I can, what I am making and hoping someone will have some advice for me.
The choice I have to made is PHP vs ASP.NET and in case of ASP.NET MsSQL vs PostgreSQL.
I must say I already spend a few months comparing and experimenting with this 2 products (and know both for many years, but for small projects).
So if I get to the point:
My web page will definitely be SPA. I don't intend to change some div content to achieve that, but open different content in dialogs or if you know KendoUI windows.
Everything else could be adapted to the selected framework. I don't plan to have many different views, but those few will heavily depend on data from database. The core of my page will be one view bind to a table with few 10/100 thousand records.
I am using jQuery to get data from server. I started with PHP, but it soon became very large project, tons of files for handling users, roles, access to file system, managing database, quering database, editing database, handling different language support... I use try version of zend studio which is great framework (you get debugger which is a little bugging from time to time) but can not compete with visual studio.
I also read on internet that all big sites (except SO) use PHP because they started small and when they became big there is no way to migrate to different server technology.
I get problems with requires files (there are to many) if I include from index.php there is different path that from AjaxCall/ProcessLogin.php. I always forgot to include some file and get unexpected result in client. ASP.NET would solve this problem. I huge disadvantage is also unknown types in PHP. I call function which return array of objects populate from database and I don't know nothing about object structure, but when using LINQ to SQL I know everything. It bothers me also that can not have 2 functions with same name and different parameters. LINQ to SQL is also amazing. And so on. Those who use both of them, you can say what advantages has developing in Visual studio c# over Zend studio in PHP.
I know (from what I read in past months) that PHP will get me better performance, that sometimes could be slower because of the interpreter. Again, I just use functions to get some data and on client side use telerik KendoUI for rendering contents.
My questions that I can not answer myself is is ASP.NET the right choise if I don't plan to use any other feature then [WebMethod] (any server side events, ASP.NET controls...)? Probably I should go with ASP.NET Web API or ASP.NET single page application? I read tutorial how can I call method with jQuery. I also found this thread. But I need to decide if I stick with PHP and do some hard work for stuff that I mention up, or I should use ASP.NET, get some really nice stuff on account of performance.
I must say that cost are not the problem. Hosting windows server, Visual studio ...
tldr; use PHP's Laravel Framework, it's a very good framework to start and it grows with you. Also it's heavily influenced by ASP.NET and Rails, just for the PHP world. Build your REST API with laravel and use jQuery for the AJAX stuff. Querying the database (e.g. postgres) with Laravel is amazing, just write something like User::where('age', 21)->get();.
Check spa-cart.com
Already much features with PHP SPA CMS
In the application I've written there is a whole class that only takes in some parameters, eventually fetches the db for other parameters, and then returns the results to the asking class. It only handles data, so it would be perfect to "outsurce" those functions to something more efficient than PHP.
I've read the official php faq page on "PHP and COM", and seen that it is not possible to run a precompiled dll from php.
So, do you think it is possible and worth to do it with some other methods? And how would you do it?
Maybe PHP/Java Bridge / RESTful WS could do, but still java does not sound like the best option (according to this post it's "clunky")
HipHop would be a great solution, but as of now it's way too early to use it in production for my needs.
All the solutions listed here seem to be aimed at creating an .exe file for making a standalone win app, whereas my app is hosted on a centOS server and I haven o need to port it to windows (or at least that's not my intention right now).
I use C++ and RabbitMQ to tie it together. I've also had success, when there wasn't much of a scope for the project, at using Redis as a tie in.
Can't say enough good things about using a message bus to separate processes (like RabbitMQ).
If you're just getting started with RabbitMQ, I'd highly recommend RabbitMQ in Action.
You don't have to use C++ though. That's one of the major benefits of using message buses; you can substitute later, if need be (and the API stays the same). Here are a list of clients that can receive and post messages to RabbitMQ: http://www.rabbitmq.com/devtools.html
Insert favorite, high-performance language here.
im just soliciting opinions/advices. Like we have this really large PHP code base, by large these are what i meant:
over 500 tables
over 4000 files - action, displays & templates.
over 1,000,000 lines of code - this software spans more than 8 years already.
So many deprecated, duplicated code all over the place, and so many hacks.
I want to be able to still run the software, while parts of it are being migrated to rails.
So it will be running in hybrid mode, that is, both PHP and rails at the same time. Parts of the software that hav been migrated already, will start using the Rails version.
I suppose my idea is:
migrate to Git
I suppose all the more than 500 tables remain.
Find a way so PHP and rails will interoperate?
Chew one display & management screen at a time?
Work on the front end?
I expect such a thing is going to be toff. Anyway let me try to give some advice.
Build both basic "runnable" applications.
Make sure that both applications can access the same database, the same session sources, the same cache and so on. Here'll you have to make sure that that your data sources are compatible to both your applications. For example: you could migrate your user sessions to the database.
Build an extra routing component (in mod_rewrite, PHP or whatever you like) to start routing several pages to your Ruby application instead to PHP. Test it thorougly. Build the router in such way that it can function in development mode as well as in production mode.
Slowly start adding routes to your router for added components in your Ruby application.
When you've completely migrated, change the default route to your Ruby application. You can start using Ruby-specific data sources now.
While I'm far from convinced that migrating from PHP to Ruby will make your life any easier, I think there is a very strong case for mapping out the dependencies within the current codebase.
Which PHP scripts are entry points to execution (i.e. map directly to URLs)
which PHP files are included by other scripts (and which are they)
which templates are used by which URL
which scripts access which tables
That will at least allow you to divide the exercise up into discrete chunks. Note that in some cases it may be a good idea to rewrite the PHP / DB as an interim measure instead of going directly to Ruby, e.g.
If there is scope for amalgamating several database tables - then do so - and create views on the resulting table named according to the replaced table.
If needed, try to re-implement every entry point PHP script as 'index.php' in its own directory - and always reference the script by the directory. That way you can transparently start replacing components written in a different language.