PHP Ajax right structure [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I found a similar questions, but it's not exactly what I am looking for.
I write web site using php. For dynamic content I use jQuery Ajax.
I have 20-50 functions and I want to use Ajax to call these functions and take JSON.
Idea is to pass parametres via ajax POST. Pages works with database and job is done.
The question - how better organize it?
Should I create 50 separate pages like:
mysite.com/ajax/delete_project.php
mysite.com/ajax/delete_user.php
mysite.com/ajax/show_user_info.php
mysite.com/ajax/show_my_messages.php
mysite.com/ajax/show_my_tasks.php
mysite.com/ajax/send_message.php
.......
or create one page? or maybe i am completely wrong with all of that

Ideally you should be using a framework, such as Symfony. Otherwise, I usually keep all the functions for each content type in a single file. So you might have:
mysite.com/api/blog_posts.php which would implement GET, POST, PUT, DEL, etc... for all the blog posts. Meanwhile, mysite.com/api/messages.php would handle that for all messages.

You must start using an MVC framework if not using already. I would say Laravel should be a good choice, it's easy to learn, feature-rich and fun to work with. Start looking into Laravel Routes.
Moving to MVC is the best way to start getting into shape in your case.

Related

How to run PHP as backend and Angular as frontend [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a project and using angular as front end and PHP as back end, installed both in different domains, PHP project is complete and working. I have created API in PHP and in angular I will call that API.
can I do like copy PHP project into angular src folder and run or using different domains how can I call API Or how?
what is the most used way for doing this I have seen tutorials over this but not able to get it correctly?
so can you please tell me any way to work,please give me your suggestion and thoughts
This is quite a big question really.
No-one will be able to give you an answer as to how to do what you're trying to achieve in a single stackoverflow post. It's like asking "how do I build a car?" - there are many steps involved to complete this process. Your best bet is to follow a tutorial.
In my experience, having separate applications for front end and backend is quite common.
You should keep your PHP project separate to your Angular project instead of mixing them.
You should follow a tutorial on how to build a full stack application such as these:
https://morioh.com/p/f2ad5d91a8dd
https://phpenthusiast.com/blog/develop-angular-php-app-getting-the-list-of-items
https://www.techiediaries.com/angular/angular-9-php-mysql-database/
Good luck!

Website/Files organisation for Ajax calls [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am just getting started with Ajax, and I wonder how to organize my ajax scripts and php files (which process the ajax function).
With Php it was easy, one functions library functions.php with all my classes and methods that I can call whenever I need them.
My first reflex with Ajax was trying to call an already existing method inside a php class in order to process a contact form but I do believe this is impossible and I need a separate file to do this ?
My question is, do I need to create a different file.js for each ajax script and a file.php for each ajax call ? It can get very messy with a few ajax functions compared to php.
Is there a right way to organize this ?
You definitely should use a php framework !
It will help you to organize your code and will bring to you some helpful features like routing which would solve your problem.
You will define some roots, each linked to a specific controller and your code will be well organized.
I can recommend you Symfony2 :
but there are a lot of which are able to do the job :
http://www.hongkiat.com/blog/best-php-frameworks/
If your application is small you can have a look to silex which is a light version of Symfony
To define your urls, you can use a REST api which is a best practice.
I can understand that you find the learning curve of the frameworks difficult but you will not regret it.

How to make a dynamic timeline using bootstrap? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to make a dynamic timeline like facebook that can post pictures and descriptions with dates using mysql php for database. I put bootstrap because I like their design, and it's easy to use.
My problem is i don't know where to begin or where do I study it.
Here's an example of what I'm talking about:
Any suggestions?
What a generic question... this seems to me an impossible question to answer but maybe you need just some little advices to begin studying the right languages which you can use to achieve what you want.
First of all please provide an image of what you want to do and more important the fundamental languages that you have to know are HTML (obviously), CSS, Javascript and PHP for some server side script.
Talking specifically about your problem, here is where you can see some open examples with well commented code that allows you to understand everything.
http://www.jqueryrain.com/2015/05/ideabox-jquery-timeline-news-ticker/
http://www.jqueryrain.com/2014/11/vertical-timeline-css3-jquery/

How to make HTML interact with a database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Hello everyone, I have a project and I want to create an MVP: Minimum Viable Product.
And I have html pages ready but I don't know how to make them interact with databases, preferably MySQL.
I need the simplest way to be able to POST and GET data from a database, PHP or Rails.
IF there's just one simple tutorial or a small ebook to read, I'll be so thankful.
I have to the end of the month to create the MVP, about 20 days or so, and I really want to make that happen and I was gonna learn the whole Rails just to do that, but it'll take time you know!
Thanks for your time and I hope that you might help me :)
You can't make HTML directly interacting with database. You should create server-side application, which answer queries generated by HTML forms, JS queries, etc. I am PHP developer, I like this language, so I recommend you using it in your solution.
You can read about connecting PHP to MySQL database here:
http://www.w3schools.com/php/php_mysql_connect.asp
There you have basic information about handling data sent by POST:
http://www.w3schools.com/php/php_forms.asp
If you have any troubles during develop proccess try Google before, then if didn't find answer ask specific and well described question on Stack Overflow.
Best luck!

PHP seamless application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Hello all and thanks for taking the time to view this.
I want to make a PHP application and I am about to start, but I want the front/backend to have as little page loads as possible, but I just don't know what to learn per se. I am torn as to whether I should learn Ajax, AngularJS, EmberJS, NodeJS, BackboneJS, etc?
I really want to know if AJAX is the same as the others I listed or not. I just want to use PHP as the engine to fetch data from an SQL DB and make the application's front/backend seamlessly.
I would like to be pointed in the "right" direction as to which technology to take.
you can use angularJS for faster loading of pages, learning path is first you have knowledge of ajax, then you can learn AngularJs.
here is a reason why you can use angularJs
http://code.tutsplus.com/tutorials/3-reasons-to-choose-angularjs-for-your-next-project--net-28457
and you are going to use PHP as Backend so it eliminate node.js from this list, AngularJs is best as you have describe your requirement, if you know bit of javascript learning cure for angularJs is easy.

Categories