- Видео 5
- Просмотров 39 735
Azeem Hassni
Добавлен 10 апр 2015
Binary Search Algorithm using PHP
Lets understand binary search using some visuals and code, we are using PHP as the programming language here but you can take concepts and implement them in any programming language, Make sure to check the end of the video you will be amazed how fast binary search is to find a number from an array of 3M elements.
Listing down the topics that are covered in this video.
1. Understanding Binary Search using a visual example
2. Implementing binary search as a PHP function
3. Testing the function with smaller datasets
4. Testing the function with datasets containing 1 million, 2 million and 3 million elements respectively.
#binarysearch #algorithm #php
Listing down the topics that are covered in this video.
1. Understanding Binary Search using a visual example
2. Implementing binary search as a PHP function
3. Testing the function with smaller datasets
4. Testing the function with datasets containing 1 million, 2 million and 3 million elements respectively.
#binarysearch #algorithm #php
Просмотров: 438
Видео
Lets Build an IoC Container using PHP
Просмотров 8772 года назад
In this tutorial we are recreating the Laravel 's magical IoC or dependency injection container that automatically creates instances of all the dependencies of a class that is resolved out the IoC container. When you're following the S.O.L.I.D principles in your application you will notice that you have to pass a good number of nested class dependencies to any class, an IoC container can automa...
Create your own PHP Router the simplest possible way - Episode 3 - Named URL Segments
Просмотров 2,6 тыс.3 года назад
In this episode of "Create your own PHP Router the simplest possible way" we are going to continue on the dynamic routes and allow for named URL segments instead of using regular expressions, of course we can still use regular expressions but this makes it so much readable that I couldn't stop myself from making this short video. #PHP #PHPRouter
Create your own PHP Router the simplest possible way - Episode 2 - Dynamic Routes
Просмотров 6 тыс.3 года назад
In this episode we are looking into adding dynamic routes capability and 404 error handling. If you haven't already I'd highly recommend to watch the episode 1 here ruclips.net/video/gVPAboBbGRE/видео.html
Create your own PHP Router the simplest possible way - Episode 1 - The Router
Просмотров 30 тыс.6 лет назад
Github Repo: github.com/azeemhassni/simplest-php-router I used PHP's built-in Web Server in this example but if you are planning to use this with Apache you can use this gist gist.github.com/azeemhassni/e819e014a80bba5c8cf9429d120a45ac to setup your .htaccess
Pretty nice lesson. At some point you said you will show when the exceptions are triggered and you didn't do it. So this was a bit of bummer. It is a valuable observation to aid the understanding of the mechanism.
Thanyou so much for sharing, keep sharing your knowledege.
Great explanation Azeem! Thank you
this is exactly what i need, thank you :)
Super !!!
Good job.
Nice ! How to implement controller and controllers method with this route ?
You can use controller methods as callbacks as you would use any other class method in php for example, ``` route('/users', [new UserController(), 'index']); ```
great explanation.
Great video! But why is it not 1200x720?
Great, keep it up Please add a little explaination of time complexity of the algo. Normally binary search's time complexity is O(log n) if array is sorted.
Great job bro..
Good work 👍🏻
Thank you!
Greate tutorial, even beginner like me understood it easily 🙂
Which IDE do you use
I use PhpStorm
Big fan 🎉
💜
HOW COULD I IMPLEMENT IT USING XAMPP
HOW COULD I IMPLEMENT IT USING XAMPP?
Source code link?
Notice: Undefined index: web/simplest-php-router-master in C:\xampp\htdocs\web\simplest-php-router-master outer.php on line 32 Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in C:\xampp\htdocs\web\simplest-php-router-master outer.php on line 34 error occuring.. not working
can you post link to your github?
Nice videos that solved the problem.❤️❤️❤️❤️❤️ A humble request. Please make videos on React and PHP backend. Suggestion: Try to write long descriptions.
Warning: Undefined array key "simplest-php-router-master" in C:\xampp\htdocs\simplest-php-router-master outer.php on line 18 Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($function) must be a valid callback, no array or string given in C:\xampp\htdocs\simplest-php-router-master outer.php:20 Stack trace: #0 C:\xampp\htdocs\simplest-php-router-master\index.php(15): dispatch('simplest-php-ro...') #1 {main} thrown in C:\xampp\htdocs\simplest-php-router-master outer.php on line 20
/ works... but /about gives a 404 error back... I am using apache server xampp
This tutorial helps me a lot...Thanks Azeem Hassni.
Algorithm series I would love to watch.
How can we add routes like $route->get('/', [TestController::class, 'show'); Where testController is a class and show is a method inside that class ?? How can we change the callback from null to accept an array..I tried that but its confusing...can you explain how to do this ??
You could get it working by changing the type of $callback to callable from Closure in the route function parameters, once you did that you can use class methods as your callback. class TestController { public function show() { return sprintf('Hello from %s@%s', __CLASS__, __METHOD__); } } route('/test', [TestController::class, 'show']);
@@azeemhassni Its still not working...You made the callback to be null...How do I get that array inside the callback variable without using the pregmatch..the pregmatch function is overriding the $callback = null variable
@@saugmaddox349 I’m not sure I follow, could you share what error you see when you try the above?
Very Well Explained...: Thanks Azim
How to add named routes to this router like laravel?? Please reply
You mean how to give a name to a route? like Laravel does it by calling the `route()->name('customer.show')`?
@@azeemhassni Yes exactly..and my recommendation is please make the router in Object oriented way..nowadays no good developer uses procedural php...
@@rxxt-sh1vj I agree, but the objective of the initial video was to demonstrate the simplest way with as little code as possible, we could probably do another series to build an object oriented router but I'd keep this series procedural/functional for the simplicity reasons.
@@azeemhassni Okay./.. i agree with you.. I will wait for your oop series for the router....any idea when you will be implementing it ??
About page not wotking localhost/about or localhost/learn/about. but home page localhost/learn working. route('/about', function () { return "Hello form the about route"; });
Hmm, are you using Apache?
@@azeemhassni yes
Well explained...!! yes continue with your reflection API...what you said..I am intereseted in watching that
Holy shot, this is actually really helpful! Thanks dude!
Thanks for the feedback Rik, it really means a lot to me, please checkout the next episode ruclips.net/video/imfPem_X4fE/видео.html I hope that will also be helpful 🙂 .
I never comment on videos but your brilliant explanation forces me to tell u that ur explanation and efforts are amazing
Thank you so much. ♥️
Absolutely agree. Been looking for a very simple explanation for a procedural PHP router for a while and this is by far the best (series) of videos I have found. Well done Azeem.
Dayum i just watched the previous video and this came out :D
Loved your comment. gave me a smile. :)
Episode 2 is here ruclips.net/video/hwNppHeKrag/видео.html
Dynamic routes are really useful. Thanks for sharing
Anytime, Hope this was helpful.
I am getting this warning Warning: call_user_func() expects parameter 1
That probably means you are registering your routes incorrectly, It will be easier to help if you share some code.
tks its very simple e much power <3
Glad you like it!
Here's a question. If something else is in the url that's not in the array (ie. wrong url) it throws an error. What's the best way to catch this and direct to the homepage instead?
I will be releasing the next episode soon, which covers dynamic routes and 404 error handling. hope that will be helpful.
@ Episode 2 is here ruclips.net/video/hwNppHeKrag/видео.html which covers dynamic routes and 404 error handling.
Thanks you for sharing
Thanks for watching!
Notice: Undefined index: projects/route in D:\wamp64\www\projects oute outer.php on line 32 Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in D:\wamp64\www\projects oute outer.php on line 34 .... ibb.co/NmGQwcj ... Pls. Help Thanks
hi... thanks I have a problem... when I add 'about' in my url, page gets an NOT FOUND error ... I used your code and just add my project folder name in the function like this: route('/project/about/', function () { return "Hello form the about route"; });
So less likes
Thanks for the comment, and liking the video. :)
how about hiding the "controller", "method" and get all the params value? ex: domain.test/controller/method/username to: domain.test/username or ex: domain.test/controller/method/?video=1212 to: domain.test/video/1212 Thanks
htacess can solve your prob
I got something best, thanks for sharing knowledge.
So nice of you, I'm glad it was helpful for you.
its not work with i had problem call_user_func() expects parameter 1 to be a valid callback, no array or string given
You must be working in a subdirectory, so you must report this in the function's arguments. For "index.php", for example: route('/subfolder', function () { return 'Hello World'; });
@anti gay anglo saxon western culture Same here
If one one you can explain the issue you are having or show me the code, I can probably help.
@@azeemhassni it's fixed by @Eskelsen solution
@@sumitkajbaje Awesome, glad to hear that.
niCe Gop
Great Job Azeem
Thanks, hope it was helpful. If you are interested I have posted another episode which extends this to support dynamic routes.
Perfectly! Show please OOP + MVC + AJAX + JSON + history api -.htaccess AddDefaultCharset UTF-8 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] -index.php <?php error_reporting(E_ALL); require_once 'route.php'; -route.php <?php $action = $_SERVER['REQUEST_URI']; $routes = []; route('/', function() { return 'Home page'; }); route('/about', function() { return 'About page'; }); dispath($action); function route($action = null, $callback = null) { global $routes; $action = trim($action, '/'); $routes[$action] = $callback; } function dispath($action = null) { global $routes; $action = trim($action, '/'); $callback = $routes[$action]; call_user_func($callback); }
what if url is dynamic like user/1 or user/profile/1????
Imran Raja the idea was to create the simplest possible solution, but if you want you can add regex or dynamic routing to it. Let me know if you need help.
thats what i need too but still have no clue
I will try to record a video on that, soon as I get some free time.
Episode 2 is here ruclips.net/video/hwNppHeKrag/видео.html which covers dynamic routes
Great