Hello, Jose, welcome to Stackoverflow.
Well... I’m not advanced in PHP, but what I do with my projects currently as regards the file structure:
|-root
---|class
------>Busca.class.php
---|php
------>busca.php
---|plugins
-------|bootstrap
-------|jQuery
---|view
-------index.php
---|js
-------index.js
Explaining basically: in class
are all the classes that I did in PHP to do mainly BD access functions, such as data entry and search. Already on php
are the files of "control" php, which is where a form goes when the user clicks on the button submit
.
You can do it in a simple way:
--index php.
<html>
<form action="busca.php" method="POST">
<input type="hidden" name="form" value="teste"/>
<input type="text" name="fieldName"/>
<button type="submit" value="Enviar"/>
</form>
</html>
--php search.
<?php
include_once '../class/Busca.class.php';
$filter = filter_input(INPUT_POST, 'form');
if (!is_null($filter)) {
$form = $filter;
}
switch ($form) {
case 'teste':
echo Busca::getTeste();
break;
}
?>
--Search.class.php
<?php
class Busca {
public static function getTeste():string {
return "teste";
}
}
Well, that would be basic modularized communication between html and php. A medica that you add js to send forms without the need to refresh the entire page, for example, things get more interesting.
This is how I basically organize my projects:
- view (php with html and forms)
- php (control files between view and php classes)
- class (php classes for accessing BD and more elaborate things)
I hope I’ve helped, any doubt I’m available!
Analysis and Modeling with UML made available online by the author himself.
– Augusto Vasques
Scrum Guide made available online by the authors originally in English and translated by the Scrumguides team.
– Augusto Vasques
Thanks for your help too!
– José Augusto Megres