CodeIgniter 4 from Scratch - #4 - Controllers

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 83

  • @cassiereardon9226
    @cassiereardon9226 2 роки тому +10

    Pasting from a reply to a previous comment... So if you are using the latest version of CI4 any controller after the default controller must use a getIndex(), getPruduct() method... index() and product() don't work anymore. Im only on video 4 so far so I will expect more routing issues later. Also the parameters inside getProduct() must be assigned a default before you can follow along. getProduct($product='whatever', $product_id='huh') can be also be an empty string. And to get to the Home controller by typing localhost/home you need to add a second route rule like $routes->get('home', 'Home::index'); Hope that helps. So far great Tutorials with that work around.

    • @VincentAzure
      @VincentAzure Рік тому

      bro you just saved me a headache thank you!

  • @storm-technologie
    @storm-technologie Рік тому +23

    if some personn get an error 404 you can simply add $routes->setAutoRoute('true'); in app/config/routes.php,
    or if you want to do manually add this route : " $routes->get('/shop', 'Shop::index');" in app/config/routes.php
    ( /shop is the path 'Shop::index' -> Shop is name of class and index, name of methode
    and that for product and product id: " $routes->get('shop/product/(:any)/(:num)', 'Shop::product/$1/$2');"
    CodeIgniter 4 :
    (:any) = for all type, letter number etc
    (:num) = just for number
    /$1/$2 = fort first and seconde prameter, exemple localhost/product/10 = localhost/$1/$2 = ($type, $product_id)

    • @aliabednar8035
      @aliabednar8035 Рік тому +1

      how come he doesn't get any errors but we do?

    • @josephjasonbuhain8253
      @josephjasonbuhain8253 Рік тому

      CodeIgniter4 updates @@aliabednar8035

    • @storm-technologie
      @storm-technologie Рік тому

      ​@@aliabednar8035 because it's not exactly the same version, this code : $routes->setAutoRoute('true'); . it's added by default in his version.

    • @storm-technologie
      @storm-technologie Рік тому

      @@aliabednar8035 CodeIgniter has removed the AutoRoute for reasons of security, it's better if you add manually like my example above.

    • @ALCaTrAzgamingSTA
      @ALCaTrAzgamingSTA 5 місяців тому +1

      thanks man really helped

  • @松田幸典-u1f
    @松田幸典-u1f 4 роки тому

    私は日本人のよしと申します。
    本当に、素晴らしい動画でした!
    今までわからなかったことが、一気に理解できました。
    これからもアレックスさんの動画を楽しみにしています。
    本当にありがとうございました!
    I am Japanese.
    It was a really great video!
    I was able to understand at once what I didn't understand.
    I'm looking forward to Alex's videos.
    I'm really thankful to you!

  • @kirkigr
    @kirkigr 2 роки тому +6

    // If you don't want to define all routes, please use the Auto Routing (Improved).
    // Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
    $routes->setAutoRoute(true);

  • @jakob9597
    @jakob9597 Рік тому

    Im a student andwe are now using code igniter in web design. This playlist ist really helpful to gain a first understanding about all this, thanks

  • @prajwalsingh
    @prajwalsingh Рік тому +3

    please make more projects related to CI4. There is really scarcity of such related topics! im learning a lot from your tutorials! Thanks! 🙏

  • @daytodatainc
    @daytodatainc 3 роки тому +1

    Great video, very good explanations on how to use controllers, namespaces and referencing them.

  • @denniscarrion746
    @denniscarrion746 2 роки тому +2

    It doesn't work on the latest version of CI 4, I think you have to modify the routing.php ?

  • @BusinessWolf1
    @BusinessWolf1 2 роки тому +1

    To those wondering how he navigates text so efficiently:
    ctrl + left/right arrow key = move the text cursor one word left/right
    ctrl + shift + left/right arrow key = move the text cursor one word left/right and select all of it

    • @n3r0z3r0
      @n3r0z3r0 11 місяців тому

      try vim :)

  • @learner4166
    @learner4166 Рік тому +1

    Why my Shop controller doesn't work without route?

  • @kallisch2000
    @kallisch2000 4 роки тому +1

    This kinda sounds ridiculous but I got an error message b/c I used a lower case in the use command ("use App\Controllers\BaseController;"). Originally it is writen as a lower case but doesn't work that way. Can you explain why?

  • @vinzanity68
    @vinzanity68 3 роки тому +1

    great tutorial, but the font on the address bar of browser is too small its almost impossible to see it

  • @rahulr4667
    @rahulr4667 2 роки тому

    How we are able to initialize $shop = new Shop(); without the use App\Controllers\Shop; in 16:23

  • @mr.techno-era7474
    @mr.techno-era7474 4 роки тому +1

    Really good video tutorial, i am feeling really comfortable because, i already knew laravel. If I'm not wrong then, structure of CI4 has somehow same as laravel

  • @jamesauble8091
    @jamesauble8091 3 роки тому

    I'm new to CI and noticing that Controller methods are being cached server-side for some seconds/minutes when i'm making tweaks to our controller. what's a quick easy way to disable caching while working on a controller?

  • @nemanjavlaovic2814
    @nemanjavlaovic2814 10 місяців тому

    I had to make a Route first in Routes.php. Is that due to a newer version or what?

  • @carlscast4572
    @carlscast4572 Рік тому

    hi alex when type localhost evething work but when i type home comes with error 404

  • @Lachausis
    @Lachausis 2 роки тому

    Any idea how to access Shop.php through .../public/ path if I use WAMP?

  • @surajpatel-kd7tz
    @surajpatel-kd7tz 2 роки тому

    i have a problem executing the new controller, please solve my issue Not Found
    The requested URL was not found on this server.
    Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.0.19 Server at localhost Port 80

  • @ArdyShazril
    @ArdyShazril Рік тому

    i wish i had view this tutorial 3 years ago. now latest CI4 diffrent. followed along and error. stuck at create controller:shop

  • @GuitaristZep
    @GuitaristZep 2 роки тому

    Help, only defauilt page is working for me I have uploaded it on the internet and not on localhost only

  • @guptarahul97480
    @guptarahul97480 4 роки тому

    can we acess the protect function using reverse routing ?

  • @lifejoin7742
    @lifejoin7742 4 роки тому

    Need guidance on
    Libraries
    As get_instance
    Url - segment
    Call libraries class function in View file
    It was easier in ci3
    Please guide

  • @shoyshai
    @shoyshai 4 роки тому

    How to load uri segments in view of Codeigniter 4 , as we do $this->uri->segment() in codeigniter 3

    • @IngPedroAraujo
      @IngPedroAraujo 4 роки тому

      As the documentation says:
      // URI = example.com/users/15/profile
      // Prints '15'
      if ($uri->getSegment(1) == 'users')
      {
      echo $uri->getSegment(2);
      }
      This applies toCodeigniter 4.

  • @varikapa
    @varikapa 4 роки тому

    Thanks a lot for you lessons! Please can you tell me why you use "return view()" instead "echo view()" in documentation for codeigniter 4 use "echo"

    • @IngPedroAraujo
      @IngPedroAraujo 4 роки тому

      Both return the same content, you can use "echo" or "return" to render the views.

  • @ayaneshsarkar7804
    @ayaneshsarkar7804 4 роки тому

    How do I autoload libraries? In CI3, it was pretty easy. But in CI4, the documentation says you have to store it in a variable.

    • @AlexLancer
      @AlexLancer  4 роки тому

      Your controllers extend BaseController ?
      If so, you can set all the libraries you want to use there.

  • @bikbjrt
    @bikbjrt 4 роки тому

    Great, making it look so easy.

    • @AlexLancer
      @AlexLancer  4 роки тому

      It is! Just follow the vids and you will be able to work with Codeigniter 4 in few hours.

  • @AtifRiazMughal
    @AtifRiazMughal 4 роки тому +1

    Thank you, much appreciated.

  • @someutubchannel69
    @someutubchannel69 4 роки тому

    Great Tutoral Alex!!
    Thanks!!

  • @sonalsahu909
    @sonalsahu909 4 роки тому

    your videos are very helpful to me thank you

    • @AlexLancer
      @AlexLancer  4 роки тому +1

      Glad to hear that! It is very inspiring that you find value in my videos!

  • @mr.techno-era7474
    @mr.techno-era7474 4 роки тому

    Currently, i am using codeigniter 3.11. I have placed my business logic in controller. It's because creating modal is time consuming. I am only developer and Projects Manager set horribly short deadline. I never able to understand the use of model? Is it for security, to absorb database changes or for anything else? Will anyone clarify this?

    • @CheefCoach
      @CheefCoach 4 роки тому

      In general Model-View-Controller system, model is responsible for dealing with database, View project information on computer screen, and controller is dealing with inputs for users.
      I have only worked with laravel, but model purpose is to make your code easier to maintenance and easier to read. For example if multiple controllers are using same database table, if you set up logic in model file, you won't need to repeat yourself, and changing code will be easier, as you only need to do it on one spot.
      But if your's project are small, times are short, and you don't care about the next guy who will have to do maintenance, carry on as you have done so far.

  • @liviubarburo
    @liviubarburo 4 роки тому

    Awesome! Big like!

  • @jaironlanda4277
    @jaironlanda4277 4 роки тому

    What extension you use in VSC?

  • @garabudastingo
    @garabudastingo 2 роки тому

    great job! thanks!

  • @LuckydPrince
    @LuckydPrince 4 роки тому

    Hi bro what do you use to re ord your screen? I use OBS in my laptop but will turn black cause of two video card

    • @AlexLancer
      @AlexLancer  4 роки тому +1

      Hi, I am using Bandicam. But it is not free. Although in my opinion it is the best.

  • @mangg0
    @mangg0 4 роки тому

    What are the php extensions u use for VS Code?

    • @AlexLancer
      @AlexLancer  4 роки тому

      Hey, check for "PHP Intelephense"

  • @fabriciohernandez3933
    @fabriciohernandez3933 4 роки тому

    thanks for this!!

  • @sonalsahu909
    @sonalsahu909 4 роки тому

    please, give more tutorial videos on CI 4 and cover as much topic you can.

    • @AlexLancer
      @AlexLancer  4 роки тому +1

      Sonal, will do. Don't forget to subscribe and stay updated! Thanks for watching.

    • @sonalsahu909
      @sonalsahu909 4 роки тому

      @@AlexLancer hey I'm also a web developer (freelance).can you make videos on Anjular JS with CI4/CI3

    • @AlexLancer
      @AlexLancer  4 роки тому +3

      @@sonalsahu909 unfortunately (or fortunately) I don't work with Angular. In near future I plan on making a project with VueJS and CodeIgniter 4 that I will publish on my UA-cam channel.

    • @sonalsahu909
      @sonalsahu909 4 роки тому

      @@AlexLancer ok thanks 😊

  • @nuklay2003
    @nuklay2003 3 роки тому

    nice job!

  • @josbexerr5166
    @josbexerr5166 4 роки тому

    Gran maestro.... gracias

  • @baliyachtservices7505
    @baliyachtservices7505 2 роки тому

    Very nice

  • @Ishowpen
    @Ishowpen 4 роки тому +2

    I like this vedos im from Indonesian

  • @TasosStat
    @TasosStat Рік тому

    You are really good at explaining the concepts but it doesn't correspond to the current version of codeIgniter. But for real you're really good at explaining😃

  • @darthgodete4352
    @darthgodete4352 3 роки тому

    very high resolution.. struggling here with the tutorial

  • @anoopck1
    @anoopck1 2 роки тому

    localhost/home = 404 error why?

  • @vinitkumar9687
    @vinitkumar9687 3 роки тому

    Hi Alex create another API related video, this video is very helpful

  • @BusinessWolf1
    @BusinessWolf1 2 роки тому

    I do not understand how he doesn't get routing errors AT ALL. I had to deal with those the WHOLE way through.

    • @cassiereardon9226
      @cassiereardon9226 2 роки тому +2

      So if you are using the latest version of CI4 any controller after the default controller must use a getIndex(), getPruduct()... also the parameters inside getProduct() must be assigned. getProduct($product='whatever', $product_id='huh') also to get to home by typing localhost/home you need to add a second route rule like $routes->get('home', 'Home::index'); Ive had to stop and start and replay the vids so much I'm only on video 5.

    • @BusinessWolf1
      @BusinessWolf1 2 роки тому

      @@cassiereardon9226 I wasn't following along, I watched to learn the basic functionality and googled my way through what I actually wanted to make.

    • @kirkigr
      @kirkigr 2 роки тому +1

      auto route is by default disabled. If you don't want to define all routes, please use the Auto Routing (Improved). Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and in Routes.php set the $routes->setAutoRoute(true)

  • @chaker7778
    @chaker7778 4 роки тому

    thanks bro

  • @digvi16027
    @digvi16027 4 роки тому

    Subscribed!
    I like your tutorials, Clear and detailed. But there is one request to you please do not upload @ 60 fps.
    30 fps is enough for tutorials.

  • @ghury1
    @ghury1 6 місяців тому

    doesn't work, as many of us already said in the comment section.