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 dont't want to use any framework, but I need a Frontcontroller, Where I can get HELP?
I would recommend building a dynamic invocation front controller. This is what the frameworks use. Here is a link to get started.
http://www.phpwact.org/pattern/front_controller
This book has a great chapter on Presentation Patterns during which he covers the front controller pattern.
PHP Objects, Patterns and Practice, Third Edition (Expert's Voice in Open Source)
http://amzn.to/d3eU0r
You should configure your mod rewriting. All requests should be go to index.php. And not domain part should be send to the GET parameter. For example: example.com/tratata/tratata.
print_r($_GET) should contains 'tratata/tratata';
Create class, which will be explode this GET parameter. It is your FrontController.
Create class tratataController.
Load class by get Parameter.
Sorry for my english.
Pick a framework and look at the implementation of their FrontController. Figure out how it works and build your own.
That said, why on earth would you not want to use a framework? The only reason I can think of is that you want to know how it works. And for that just google and look at existing sources.
I have had the same issue, so I made my own. It's tiny, as the name suggests, and (hopefully simple to use. You just need to make sure that the correct Apache rewrite rules are in place. You can find the source on GitHub. https://github.com/samuelwilliams/Tiny-Front-Controller
Related
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!
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.
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 always use controller files for my project. Sometimes i get confused when to create libraries. Can you please let me know when do we create libraries files and for what purpose?
I can simply define as following:
Controller: This entry point of your application which is associated with URI.
Helper: Helpers are written in procedural format rather than OOP format. Small scale tweaking is handled by this. As the name suggest Helper file helps the main application controllers in some ways.
Library: Libraries are conventionally reusable code which can be used over different projects.
So if you want to write a library that should be reusable and generic. or it will be a waste of time and effort.
When you need to use any code for several portion or projects, you can create library for better understanding and easy access. Suppose, you want to use any user defined captcha generating function, you can create a library and can use it for several projects.
When you are writing some code that is not specific to current project only and it can be reused on other projects then you should create a library.
For example, I have some generic controllers that I use in every project, I put them in libraries and load via __autoload.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i am making an application using mvc structure. In that when the controls go from controller to model step then it comes back. i want that Ajax request should go directly from model to view rather than going to controller and then to view....
Why would you like to use the MVC pattern at all when you then want to ignore it? This does not make any sense at all.
Technically what you want is possible using a dispatcher filter and getting an instance of the model via ClassRegistry but bypassing the controller step disables any kind of auth checks, components and well, views as well. It totally makes no sense.
If you want to build a messy application go for the dispatcher filter or don't use a MVC framework at all.
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 4 years ago.
Improve this question
I am not trying to create yet another web framework.
For one of the applications I am working on, I want to create a custom framework. I don't want to use any already available framework.
What are the common things to consider?
What should be the architecture?
Thanks :)
If the point of a framework is to make tedious things easy, a good start would be to consider what is tedious.
What are the common things to consider?
Purpose. Usually, when you start building a piece of software, you have a purpose in mind. What will it do that other programs can't?
If you can't answer that question, then take any existing open source framework, change its name and your job is done. Now you have your own framework.
Well if you are going to write a custom framework then I assume the framework needs to be tailored to your needs, otherwise you would use one that is already available. So figure out what your needs are and go from there ;)
What are the most often repeated operations in your application? Is there a division of labor that a framework could make more apparent?