Implement page titles and improve form rendering - Part 7 | PHP MVC Framework from scratch

preview_player
Показать описание
I have built an MVC framework on PHP from scratch.
In this video we will implement user authentication and saving authentication user in database.

⭐⭐Source code⭐⭐

Here are several features of the framework:
- Custom Routing
- Composer
- Controllers
- Views/Layouts
- Models
- Migrations
- Form widget classes
- Processing of request data
- Validations
- Registration/Login
- Simple Active Record
- Session Flash messages
- Middlewares
- Application events
- Framework reusable/installable core

=========================================================
------------------AUDIO GEAR I HAVE--------------------

------------------CHEAP AUDIO SETUP------------------
=========================================================

Follow me on social media:

Check my Github:
Рекомендации по теме
Комментарии
Автор

Great series. Learned a lot from it about backend frameworks and OOP.

headlikeahole
Автор

Your explanation is more than wonderful, but please make an example about modifying data and updating data in this beautiful mvc project.

osamapro
Автор

thank you giving wonder full videos sir, very good content.

shaikhanuman
Автор

Where would you load your css files ? In public ?
Great series

WIMON
Автор

Hi, thank you @Zura for the video series, someone then solved on a file type input on this project because I tried, but I encountered an error that the field is empty, anyone have an idea please ?
Thanks

resoluion
Автор

Hi @The Codeholic,
in this framework you haven't spend any time to REST with JSON,
how did you solve that? Controller/Http/<controller> Controller/Json/<Controller>?

And how do you manage Lists eg. Users?

What did you think about removing the .env* and put it into a
eg.

<?php
return array("db"->array("name"=>"main", "environment"=>"<serverid>", "type"=>"pdo:mysql", "server"=>"localhost, "port"=>"3307"....);
serverid means (db connection : local installation or live-server) i solve that in my case with cr32 <- domainname and or filepath :o)

Thanks for your tips and tuts!!

florianbanowski
Автор

local css files are getting redirected to not found

deepaknmurdeshwar
Автор

ive been trying to add tailwind but it cant seem to find the css in public/dist/output.css

pvpete
Автор

Sir pls can u make video on how to make web scripting language like php

bigbang
Автор

спасибо за видео. А когда будет авторизация?

topalek
Автор

For those Wondering how you would be able to add parameters to the url, I worked up a solution based on some previous scripts, it works brob could be prettied up quite a lot but it completes. Note that you pass the route array by method in the router resolve method, put this function into the request and set a public array $params in the request class. This is the function:

/**
* Method to fetch parameters from the request URI and attach them to the named parameters in the route
* Parameters are defined using {[name]} eg {id}
*
* usage:
* /user/{id} ===> /user/5 the request object will hold a params array its an assoc array of key value pairs. like: ['id' => 5]
*
* @param array $routesList Path of routes based on the used method must be passed via the router eg [get => [/user/{id} => callback]]
* @param string $uriPath URI passed from the server is the /user/5
* @return string returns the route path for use within the router, or will return the original uri path passed for it to 404 fail
*/
function parameterSearch ($routesList, $uriPath) {
$newRoutesList = [];
// 2 filter routes to the same number of steps in the uri
foreach ($routesList as $route => $callBack) {
// if this is a direct path match then exit and return immediatly no need to continue through the whole process.
if ($route === $uriPath) {
return $uriPath;
}
$routePath = preg_replace("/(^\/)|(\/$)/", "", $route);
$uri = preg_replace("/(^\/)|(\/$)/", "", $uriPath);
if (count(explode('/', $routePath)) == count(explode('/', $uri))) {
$newRoutesList[$route] = $routesList[$route];
}
}
// 4.a check see if they are a direct match if they are that is the route to use
// 4.b if not then check route string for '{}' in them
// 4.c check with match should it work then extract params and run the route.
foreach ($newRoutesList as $route => $callback) {
preg_match_all("/(?<={).+?(?=})/", $route, $paramMatches);
$uri = explode('/', preg_replace("/(^\/)|(\/$)/", "", $route));
$uriPathArray = explode('/', preg_replace("/(^\/)|(\/$)/", "", $uriPath));
$params = [];
$indexes = [];
$paramNames = [];
if (count($paramMatches) > 0) {
foreach($paramMatches[0] as $key){
$paramNames[] = $key;
}
}
$matchFailed = false;
foreach($uri as $index => $param){
if(preg_match("/{.*}/", $param)){
$indexes[] = $index;
} else {
//see if uri path array has the same value, if not then its not a match and should be broken out of and to the next...
if ($param === $uriPathArray[$index]) {
//matched so can continue
continue;
} else {
$matchFailed = true;
// didnt match so break out of this and then continue
break;
}
}
}
if ($matchFailed === true) {
// match wasnt found on that pass and soo moving to the next route in the list
continue;
}
// match found so now we are rebuilding teh path and returning that route back for the
foreach ($indexes as $key => $index) {
// no no happened

return false;
}
$params[$paramNames[$key]] = $uriPathArray[$index];
}
//resetting parameters to teh request object
$this->params = $params;
return $route;
}
// possibly not found, maybe it wasnt caught else where and will likely throw a 404 error
return $uriPath;
}

JesseFender