More Fun with use Statements

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:07
    I hate needing all these require statements.
  • 0:11
    But thanks to our autoloader, the only thing we need to do is
  • 0:15
    give every class the namespace that matches its directory.
  • 0:20
    This will be a little bit of work because we didn't do it up front.
  • 0:24
    Life is much easier when you use namespaces like this from the very beginning.
  • 0:30
    But we'll learn some stuff along the way.
  • 0:33
    The AbstractShip class lives in the model directory.
  • 0:36
    So give it the namespace Model.
  • 0:39
    Copy that and do the same thing in BattleResult,
  • 0:44
Loading ...

More Fun with use Statements


In this PHP tutorial, learn how the use statement works with the autoloader to replace the require statements that we removed in a previous lesson.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.