Best solution for a database driven web application? [closed] - php

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I have been planning out the development of a web application written in PHP using the CakePHP framework. This application will be heavily dependent on a SQL database. The primary intent of the application is to provide HTML forms for adding, managing, and removing data from this database. It will be a descent sized database (1-2 dozen tables) and there will be a good number of links between them. There may also be some reporting on the data (would like to export to Excel/CSV or similar).
So here is my question, does anyone know what solution would be best for this type of situation? If this application was developed fully in PHP/CakePHP it would take quite awhile to develop by a single person and require the input of a developer to add/remove/update the database structure/fields. However I can provide much more custom interface tailored for the needs of the application and it will be web based (accessible anywhere). But there are also solutions such as Filemaker Pro that can provide a similar solution. Does anyone have experience with such applications and solutions?

I develop web applications using CakePHP and MySQL Full time for my current employer, so I'll try to answer your questions from experience:
does anyone know what solution would be best for this type of situation?
Any PHP Framework is a great solution for your problem model. I prefer CakePHP because it allows me to rapidly deploy applications, and it favors convention over configuration.
If this application was developed fully in PHP/CakePHP it would take quite awhile to develop by a single person and require the input of a developer to add/remove/update the database structure/fields.
From what you're telling me, your application will be mainly a CRUD app. A CakePHP installation comes standard with the features you need for this. Even better, you can use the CakePHP Console to "Bake" your application. This will automagically generate all of your Models and Controllers, and all of the views you will need to add/update/delete records from the tables.
The only preparation you need to Bake the app will be:
Creating the Database
Naming all of your tables following conventions from the documentation.
Ensuring you have all of your foreign keys in the proper place, following naming conventions.
At this point the Bake Console will get to work building models, discovering relationships, and generating code for CRUD operations. That's right, you'll be 70-90% DONE (based on your current, vague specifications) with the functionality in about 10 minutes after building the database. From there you will need to flesh things out with your own designs, security, and functionality like reporting.
It really is easy.
Now that I've said all of that, you'll need to know a couple of things:
To properly optimize CakePHP configuration takes a bit of experience and/or magic. Getting your application up and running is a veritable piece of cake. Making it run well takes some effort to make sure you use best practices. Search for variations on "Optimize CakePHP" in google and review the blogs you find.
The Containable Behavior is a blessing and a curse. By all means, put it in your AppModel to make everything "Containable." But, try not to use containable to find data from deeply associated models. Cake will barf out a few hundred (or thousand) Select queries, and your app will start to crawl/fail.

You can try out the Agile Platform by OutSystems. You can model your web applications visually (including all database details, web pages, logic, ...) and then generate a standard .Net application using a SQL server database.
Once you define the database structure, you can drag&drop tables into the pages to automatically create CRUDs. This greatly simplifies the implementation of web pages that manipulate data. These " wizards" will also create all the pagination and column sorting (when you're listing data from a table), as well as the pop-up forms (with field input validations) needed for users to input data.
Last, but not least, if you make changes to the database structure, the platform will automatically update all pages and logic (like queries) that you are using, and will pin-point all the elements you need to manually change to ensure the app is consistent.
You can download the Agile Platform for free at http://www.outsystems.com/download/ and give it a try.
Cheers
Michel
PS: I work at OutSystems

Related

Advice needed for a small web application's architecture/implementation [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I was asked to build a website where a company's employees (around 20) could login and fill in their working schedules for a present and past (if needed) month. Employees should ofcourse only be able to see their own schedules, but the manager should have the privilege to access every schedule.
I have little experience in web development therefore an advice is needed. I have already created a PHP/MySql login page. Now what? How do I go about it?
Just some architectural or implementational(if you will) guidance would be really appreciated.
I have built applications similar to this in PHP / Mysql and can say that it's a good platform for it, although something like Rails might be quicker to use and require less micromanaging. As Wisdom says, use a framework to cut out some of the grunt work and ensure you're adhering to good security practices.
A few things come to mind that you'll need.
Clarity about what your database structure will look like. Try to identify: a) all the pieces of information you'll need to store (A user's name? login info? "authority" level to see others' entries?), b) what tables they can go in. (Can "name" and "hours worked" go in the same table? If they are different levels of analysis, should they go in different tables? Are those two bits of information connected somehow? If so, how should I represent that connection?) Relational design is your friend, especially if you're building something that might get revised later. Take the time to understand what it's about.
A page (view) for each different "type" of activity, would be a good place to start. So have a "Let me see my schedule" page, with links to a "Let me add a time entry" page and a "Let me edit that time entry" page. My experience is that, striving to keep your "view" pages' code as small and easy-to-read as possible, pushes you to better plan your code structure.
ANY values that you insert into a query string, should be sanitized. So queries to search or select values should always have any PHP variables filtered through a "cleaning" structure:
$query = sprintf("SELECT * FROM table1 WHERE identifier = %s",
mysql_real_escape_string($id));
Rather than:
$query = "SELECT * FROM table1 WHERE identifier = ".$id
because any text which a user types into a search or insert field online, if it ends up in your query, could be executed as part of the query. A hacker could then use this to make your other security features useless.
I would recommend to select a framework like cakephp or symfony this way you can avoid some mistakes. if you want to create by your own
first decide the database architecture that will fullfill your need.
than try to make crud functionality for each table as php object.
I think this can make you get going
I was heavily involved in the design of our company's internal dashboard, where employees can log-in and view pertinent company metrics. We used CodeIgniter as our framework and it worked really well! It's a PHP framework that uses MySQL, which we already had both PHP and MySQL installed on our servers. There were already a few people in our company who had experience with it, as it has been around a few more years and is more established than the latest and greatest fad frameworks. It has worked beautifully because of its MVC approach to development. We have attached it to our home-cooked database using Grocery CRUD. It has plug-ins that handle user authentication, sessions, and security. We have been extremely productive with it and I highly recommend. Keep in mind, this framework is designed for developers that want to create something very customizable. That being said, it provides basic things you need but lets you handle the higher-level stuff yourself.
You will need to design your database to meet your real-world constraints.
With MySQL you can create a relational database that reflects users and their positions. We created an E-R Diagram first to help our company's executives visualize the constraints and how we could model our business via the database, so that they could be involved in the discussion during the design phase.

Creating an API (with PHP) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I been having this idea spooking around in my head for 2 weeks now. I’ve finally created some cases and plans on where I want to go with this project. I will have to create both a web application (ASP.NET) and a desktop application (Java). Both these applications will need to have sync’d databases.
I’ve been thinking about creating a public API over my database so my front-end and 3rd parties could communicate to the database. But I’ve never really attempted something like this before. I’ve spend my weekend so far on reading up on how I could approach this and I’ve gotten a pretty good idea. I’m having some questions/doubts currently and was hoping perhaps someone could help me.
1) I’m currently still in university and I don’t have a job so my pockets don’t go very deep. I’ve been thinking of writing the API in PHP, I already have possession of an unmetered hosting account and else I would be forced to buy .NET hosting which can turn out to be quite expensive. However my PHP knowledge is quite limited towards parsing user input/security. Would it be wise to search for an (e)book around this topic or would I be fine with online tutorials, do you have any suggestions on where to look? Should I put my time in writing a possible vulnerable PHP API or should I look at other options?
2) So far I’ve never really had the need to look into PHP libraries. I was wondering if I should look into some of these (for example cakePHP) to help me develop the API.
3) I’ve experience with implementing Twitter/Linkedin their API’s so I’ve been thinking to use OAuth (v2) to allow people to use my API. Is implementing OAuth to your API a lot of work? Is it well documented enough for someone with only basic PHP knowledge? If you ever used it on your API, what was your experience with it?
4) If this project would ever kick off, it would be wise to look into hosting It in the cloud. Do I currently need to think about something so future cloud integration is possible?
5) For the web application, would there be a (big) performance difference between using the API or directly connecting to the database?
6) Any recommended lecture or tips are welcome. It’s the first time I will be attempting something this big (both in functionalities & required knowledge).
1) Developing a simple API is not that hard with PHP if you have some experience in other languages. Ofcourse, every language has its own way, and when it comes to optimization and stuff like that, you may need some more PHP knowledge.
2) Using a PHP framework would definitely help with the lots of aspects. I use symfony 2 for all my PHP projects. I really suggest checking it. It's a decoupled framework, and you can use individual components from the framework. It's lightweight and fast, and offers great tools to build what you want. What is symfony? explains the benefits. Also, using ORM (I prefer Doctrine) is an option, but this is a whole another topic.
3) If you decide to use symfony2, there are bundles (libraries) for it that you can use. It shouldn't be too hard to implement even without a framework, but I don't have any experience in that area.
4) I don't have any experience in cloud, so can't comment on that.
5) There will be a performance difference as you are adding another layer to your project, but whether it will be a big or small depends on the API, database etc. But, using an API will mean a standard way to communicate with the database, so even with the performance difference, it might be beneficial in terms of consistency and development time(you won't have to deal with different platforms to do database stuff.).
6) The usefulness of the API greatly depends on the application and I can't really say if it outweighs the costs without specific information about the project. But having a standardized way to communicate with the data storage is generally a good idea when dealing with multiple platforms and languages IMO. As I don't know how much do you know about PHP, I can't comment on if it will be worth your time. I would go for it if there is enough time, as learning about PHP would add some more tools in your arsenal and this will be a good opportunity to improve yourself as a developer.

Should I not use CakePHP or MVC for this app? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been working for a company for the past several months as a kind of general developer/IT guy. I wrote a web app for the company that is hosted locally. I used CakePHP and MySQL (because the application fit the Active Record scheme really well).
The new web app I am working in is going to be used to analyze monthly sales data. Essentially, we get a humongous dump of information every month that I need to analyze...
Every month we get a huge table of data that has every one of our clients info (their ID#, how many $$ they processed, how much we made off them, etc.). Call this RESIDUAL
We also get another table that basically has their ID, a "description" (basically the type of expense), and a value. Call this INTERCHANGE
I have a permanent table called REPS that has each Sales Rep ID, their name, etc.
In order to get useful information (like the client name), I delete and reupload another table that has info like their Name, State, Status (if they are active or closed), etc... monthly.
I decided to make a residuals table that records the month as a column and I just add to it each month.
My problem is that working with CakePHP is getting pretty difficult. Say I want to get a table that has columns for each month and rows for each Sales Rep. It starts to get really complicated because this is NOT an Active Record application and I am having to do all sorts of long complicated find statements.
Would you recommend changing to a different framework, language, or database? What changes in Database structure should I make? My Controller is INSANELY long, should I shift more work to the Models?
Any ideas?
Edit: I need to create a system where my not-as-technical boss can easily run whatever sorts of analyses she wants.
Edit #2: Thanks for the responses. Yes I know SQL queries pretty well, and I actually started off just doing my own thing, but then I restructured the DB and converted to Cake right after that.
That's an extremely open ended question, as such you won't get a perfect answer. I can only throw in my two cents that Cake is not tuned for a database heavy application. By that I mean anything that is not simply CRUD record inserting, retrieving, updating. The Cake DAL does not scale well to accommodate complex queries or mass-data insertion/updating/manipulation.
Having said that, there's still PHP in CakePHP. You can issue "manual" queries using the model's query method. You should create methods in a model that does the heavy data lifting; such code is business logic and does not belong in the controller. In the model use regular PHP and SQL code to process data.
If this is pretty much the only thing your app does, you may be happier without Cake and just some thin wrapper around your own database connection like PDO. That forgoes Cake's nice routing, forms and views though, so you have to decide what you prefer to spend time on.
Examine your options first. Do you know any other frameworks? Do you know how to setup a plane Jane PHP app with your own MVC? A lot of components in frameworks can be found independently and added to your own application (like Active Records, Dependency Injection, Auto Loading etc, etc)
If the framework you are currently using is making it hard for you to get things done, then you should consider getting rid of it. Using a framework should make things easier, not hard. And the thing about CakePHP is that it goes by the mantra 'Convention over Configuration'. While it's great for getting out a certain type of new application off the ground in no time flat, it's not suitable for everything.
Since I don't know much about your project, I can't really help you choose a framework. But from my past experience, Zend Frameowork and CodeIgniter have been the most flexible. ZF also offers a good CLI structure as well, in case you need heavy duty crons running all the time. That being said, use these only if you really need/want a framework.
Having really complex controllers isn't a good thing. This might indicate that your models aren't doing enough work and most of your transformation is happening in your controllers. Your models and your views should be doing the bigger part of the work. I usually aim for thin controllers and fat models.
Have you considered other frameworks?
Symfony (I use 1.4.*), for example, can use Propel as its ORM. Propel is really well designed and it makes use of a Query object that makes getting data from the database really easy. It also allows for custom SQL queries to be written should you need to resort to that.
To answer your question, even though you're asking specifically about Cake PHP it sounds like the "This is too much" argument; as in "Using such and such framework is too much for this project". In my case, I prefer to deploy every project using a framework an plugins that I carry with me and invest time in knowing really well. They save me time and I don't have to think about basic plumbing code in every project I start.
A framework provides a lot of tools (besides the ORM), like routing, validation, etc that come very handy in almost any project and not having them really can slow you down a lot.
I would recommend you have a look at other options if you feel CakePHP has become cumbersome as I am very certain using a framework is the right choice.
I have a good and a bad news for you. The good news is that you started very well with Active Record, and CakePHP. The bad news is that your DB structure is not quite OK.
Read a little about Database Normalization and learn how to normalize your DB and data.
The first problem I see is that you add a column for each month. You should really have 2 more different tables:
1 for months - this can hold months name, and some super aggregated data like the total amount of sales for that month for the whole company
1 that will be the pivot table between REPS and months - in this you'll hold rep's id, month_id and possibly some information related to the sales of that rep for that month.
In the end you will have a many-to-many relation between reps and months. ActiveRecord will be more than happy, the MVC also, and also the developers that will work with or after you because this is how it should be done :)

When a Web framework isn't convenient to use? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
When a Web framework ( like django, ruby on rails, zend, etc ) isn't convenient to use ?
And so... When a Web programming language ( like PHP, Asp, Python, etc ) is better than a Web Framework ?
I like the wikipedia description:
The framework aims to alleviate the
overhead associated with common
activities performed in Web
development. For example, many
frameworks provide libraries for
database access, templating frameworks
and session management...
Basically if you don't need all of the above, you don't need a framework.
You don't need frameworks when you don't plan to use their features.
The difference is, in my opinion, the simpleness of what you are trying to build.
Are you trying to make a difficult, complicated web app, or are you making a simple script that performs a trivial task? In the first case you absolutely need a framework, in the second case.. don't even bother.
The rule that I have is that if whatever I'm building is only going to be a single page, I'll usually do it in just PHP. Whenever I need more than one page, I go with a framework (Symfony), because that usually means that I'm going to want things like routing and proper dispatching of requests.
This does however depend a lot on the language. In languages like PHP, the time needed to set up a project to use an MVC framework may be a lot more than just solving the problem. Other languages may very well be designed around using an MVC framework, and has a very low setup cost for that.
A web framework is supposed to provide means to handle certain kind of interaction. If you have site with no interaction or no "adaptation", you don't need either framework or programming language, you simply write HTML files and publish your files.
As you start to add features for the back-end (like publishing more plain pages) or in the front end (like sorting a list when the user clicks "order by") you start getting into frameworks/programming languages.
Basic interaction was handled with CGI - you write an script which responds with a string to a few parameters passed via a form. Then you have database access.
In my experience, if you need simple features AND want your website to be suitable for growth without resorting to rewriting it from scratch, you should start from a web framework like Django. You can do simple things quite easily in Django (granted - it is not trivial) and add very complex behavior with small, incremental steps.
When you have to build a very complex site, and the functionality is already exists in a CMS (eg Drupal, it has amazingly lot contrib for everything).
I'm at that stage where, because I spent so much time learning a framework recently, even if I do a one page "website", I will still use one, need to get my ROI up :p

CRUD for MySQL and PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have to make some database requests with PHP on a MySQL database.
Question : What is the best (simpliest) framework to get thing done right CRUD (Create Read Update Delete)?
I also have to populate the database, what is a good tool to do that. The only one I know is SqlMyAdmin, wich does not look good. An online tool would be great.
Your experience is valuable: tell me what do you use and why ?
I have taken a look at CodeIgniter, looks nice, what do you think... overkill ?
For lots of operations (especially CRUD, which work out of the box once you've written the schema files), the ORM Framework Doctrine is really great.
If you want to go farther than just DB access, you might take a look at the PHP FRamework symfony, which provides an admin generator (there is even a screencast about that one).
(And has great documentation, such as the jobeet tutorial)
(BTW, symfony uses Doctrine as ORM ^^ )
But maybe it's a bit overkill (and requires a too big learning curve) if you need something simple...
To load data to MySQL, what about LOAD DATA INFILE, which (quote from the docs) "reads rows from a text file into a table at a very high speed".
I recommend GroceryCRUD because of the good engineering and documentation
Copy files into your web folder
Configure MySQL database
Specify MySQL table name
=> You get a paginated JqueryUI table with create/edit/delete buttons.
create/edit opens a form page based on the MySQL table schema. For example, a boolean, a varchar and a text get turned into a form with active/inactive radio buttons, a text field and a wysiwyg html editor.
Note: GroceryCRUD is built on CodeIgniter so you will have a copy living in your admin directory. You don't have to use it for building your main site.
Security Advisory: Any library can have undiscovered security vulnerabilities, so it is recommended to minimize exposure by protecting your copy of GroceryCRUD with BaseAuth and permitting SSL access only.
I'd second Pascal's comment re Symfony (I would uprate but not enough credit :-() - Symfony has a great admin generator, and once you get your head around the app->module->actions concept, it's straightforward and the documentation is fantastic, even if it is sometimes easier to search Google for it ;-)
Failing that, CakePHP is a lot better now than it used to be back in the early days, and you can get going with the minimum of fuss, particularly with their scaffolding which will help you set up a basic CRUD-style setup. Their documentation is also pretty awesome and very easy to read :-)
If solutions such as Doctrine, CAKE, CodeIgniter, etc. seem like overkill for what you're trying to do, I'd recommend a one-file PHP script I built that lets you CRUD hierarchical data in MySQL:
http://coding.pressbin.com/109/PHP-One-file-CRUD-front-end-for-hierarchical-MySQL-data/
Why do not you try to code it from scratch as CRUD is a common task of programming.
There are lots of good tutorials:
1>PHP PDO + Bootstrap Twitter: http://www.lizardgrid.com/blog/php-crud-tutorial-part-1/
2>JQuery + PHP: http://www.codeofaninja.com/2013/05/crud-with-php-jquery.html
I am currently testing JqGrid (a Jquery Table Library).
I have tried Grocery CRUD: looks nice, but its Datatables theme (which has column filtering ability) won't work with server-side processing, that's why I dropped it.
You may have a look at Cygnite Framework
It does basic code generation. Controller, model, views, layout, pagination, form component, required field validation, with bootstrap template etc. all these generate with simple command. You may alter the code based on your need.
Here is the tutorial- Generate CRUD application within 2 Min
Worth looking.
I'd say that totally depends on what you need to do.
You do know phpMyAdmin, right? You can import from a lot of formats with that tool.
Or do you want to develop an application with simple CRUD operations? Then a framework like Symfony or Zend Framework would be the right thing to be looking for.
I developed this script which reverse engineers from a MySQL database a set of stored procedures that list all the rows of a table, a single row based on the primary key, updates/inserts based on the primary key and deletes based on the primary key. It assumes that you already have your tables created with the primary keys setup per table and it generates the MySQL stored procedures for you. I have found that this is more efficient than similar types of solutions developed in PHP.
Something like http://www.notorm.com/ might be more appropriate than Symfony. Whilst I like Symfony and have used it to great effect, it is not simple.
Likewise with Codeignitor I would argue that any full stack framework (Laravel, Zend, Wii etc . . ) would not fit the remit of "simple".
A fairly straight forward and effortless crud system i found is https://github.com/usmanato360/crud360 its very easy to setup and there are loads of advanced features. It is unlike traditional crud systems that generate model classes etc.. it is just a single class that takes care of everything dynamically.

Categories