How to build a router in PHP (like Laravel) 2022 - PHP Project - PHP Tutorial Beginner to Advanced

  Рет қаралды 9,493

AMIR KAMIZI

AMIR KAMIZI

Күн бұрын

In this PHP tutorial I'll talk about building a router in PHP. this might look simple but it's very powerful.
🎓 PHP Course Beginner to Advanced:
www.udemy.com/...
💖 Show Support:
www.buymeacoff...
📧 Join Newsletter:
amirkamizi.com...
👇 Follow Me On Social Media:
Twitter: / amir_kamizi
LinkedIn: / amir-kamizi
👇 Checkout My website
amirkamizi.com
Thank you for watching.
If you found it useful:
✔️ Like & Subscribe
✔️ Share
If you have any suggestions, questions, or opinion, please leave a comment below. I’m looking forward to hearing from you!
⭐️ Contents ⭐️
0:00 - Intro

Пікірлер: 39
@AndrewKwabula
@AndrewKwabula Жыл бұрын
I like your teaching style, even more I admire your depth of PHP knowledge. This is really helpful.
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you very much. I'm glad to hear you liked it
@Asp.net_Developer
@Asp.net_Developer Жыл бұрын
The only php guy i recognise his ability of simplifying php is a top tier. God bless bro🥷 all love brother
@amirkamizichannel
@amirkamizichannel Жыл бұрын
oh thank you very much for your kind words. I'm glad you liked it.
@thehunter11
@thehunter11 2 ай бұрын
The goat !
@amirkamizichannel
@amirkamizichannel 2 ай бұрын
Thank you very much. I'm glad you liked it 🙏🙏
@BruceElgort
@BruceElgort 4 ай бұрын
Wonderful video! I also have it working with query parameters. Had to modify the regex.
@amirkamizichannel
@amirkamizichannel 4 ай бұрын
Thank you very much.oh yes changing the regex to be able to take into account the query parameters is very good. thank you
@jadidlar4765
@jadidlar4765 Жыл бұрын
Great Job! Thank you. I always have been interedted in this topic
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you! I'm glad it could help you
@monzur
@monzur 11 ай бұрын
That's an awesome project. Thanks. I think here we, need to handle the 404 error page. Otherwise, a user can't determine that's the right path. here I share my little code to handle 404. if (preg_match($pattern, $currentUri)) { // do something }else{ //Here we can load 404 controllers or just print the message }
@amirkamizichannel
@amirkamizichannel 11 ай бұрын
Thank you for sharing that. exactly we can create a fallback route so in case it didn't match anything we would show a 404 page.
@MohammadDLitoo
@MohammadDLitoo Жыл бұрын
keep up the good work man !
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you very much Mohammad 🙏
@rerain8193
@rerain8193 Жыл бұрын
many thanks i rally struggled with the redirecting thing much love
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you. I'm glad you find it helpful
@MasoudHatami-t2b
@MasoudHatami-t2b 8 ай бұрын
why does print_r($SERVER['REQUEST_URI']); is empty
@amirkamizichannel
@amirkamizichannel 8 ай бұрын
sorry for late response. I hope you've figured it out till now. if it's giving you empty result check your .htaccess file and your directory and make sure it's pointing to the right place.
@cristhianjhlcom
@cristhianjhlcom Жыл бұрын
Hello, I just found your channel and I think it's awesome, I'll check out all your videos. :D keep up the great work 🐘
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you very much. I'm very glad to hear that! :)
@nagdali9209
@nagdali9209 Жыл бұрын
Where are you from long ago? My man
@amirkamizichannel
@amirkamizichannel Жыл бұрын
oh thanks man for asking. I've had some issues that I was trying to deal with but now everything is much better and this week I will upload new content again. I hope everything is going well with you
@ftmullah
@ftmullah 6 ай бұрын
W video
@mastro870able
@mastro870able Жыл бұрын
Great Job! Thank you
@amirkamizichannel
@amirkamizichannel Жыл бұрын
Thank you Michal! I'm glad you liked it
@machinelearning2578
@machinelearning2578 Жыл бұрын
Thanks a lot, could you please share the code?
@amirkamizichannel
@amirkamizichannel Жыл бұрын
offf I've just seen your comment. sorry for such late response :) I'm glad you liked the video. my main goal for these videos is that I go step by step so the learner could go on and actually code the project themselves. that's why I haven't shared the source codes.
@NedumEze
@NedumEze Жыл бұрын
Thanks Amir for this. Please, may I ask? If your index.php were in a "public" folder, how will the RewriteBase rule be then? Will this be correct: /php_course/public ?
@amirkamizichannel
@amirkamizichannel Жыл бұрын
I'm glad you liked it. yes exactly. if it was in localhost/php_course/public then you would write /php_course/public. but note that the base path for the project and the location of index.php file are 2 different things. for example in this video the project was in php_course so in the browser I would go to localhost/php_course so if for you it's in php_course/example you would need to go to php_course/example. this would be base path of the project. it would be good if the index file is in the base path. it can be in another folder but it might create some unexpected behaviours. for exmaple your base path might be example and your index.php file might be in example/foo/index.php. you can make it work but it would behave a bit "strange" :) take a look at apache documentations httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase and httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule I hope I could help you with you question
@NedumEze
@NedumEze Жыл бұрын
@@amirkamizichannel Thanks a million, Amir. So helpful. I deeply appreciate
@amirkamizichannel
@amirkamizichannel Жыл бұрын
@@NedumEze It's my pleasure
@NedumEze
@NedumEze Жыл бұрын
@@amirkamizichannel I took up your challenge Sir. Implemented Composer Autoloader and populating the remaining Methods in the Models Folder. Truth? It's hard! And I am struggling. Question: The files in the Views Folder should be mainly HTML pages AND NOT CLASSES?
@amirkamizichannel
@amirkamizichannel Жыл бұрын
@@NedumEze I'm glad to hear that you took the challange. I'm sure you're going to do it. yes the views can be .php files and inside them the format is like a normal html file. there is no need to use classes. later you can use a templating language like blade that laravel uses.
Girl, dig gently, or it will leak out soon.#funny #cute #comedy
00:17
Funny daughter's daily life
Рет қаралды 46 МЛН
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Apple peeling hack @scottsreality
00:37
_vector_
Рет қаралды 127 МЛН
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 494 М.
PHP For Beginners, Ep 33 - Build a Better PHP Router
20:46
Laracasts
Рет қаралды 22 М.
Why is Laravel NOT used in Big Development Projects?
11:53
Stefan Mischook
Рет қаралды 179 М.
Laravel CRUD in 50 minutes for Beginners  from Scratch
49:58
Devtamin
Рет қаралды 212 М.
PHP Framework Pro (Create a PHP framework step by step)
1:12:14
Gary Clarke
Рет қаралды 28 М.
Custom PHP OOP Router without PHP libraries
34:15
Max Pronko
Рет қаралды 37 М.
Girl, dig gently, or it will leak out soon.#funny #cute #comedy
00:17
Funny daughter's daily life
Рет қаралды 46 МЛН