Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using namespaces in Laravel 4

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 341
    Comment on it

    Namespaces plays an important feature of php. Namespaces are used to solve 2 major issues.

    1) Authors of libraries
    2) Applications encounter


    Laravel 4.x also provide namespace to solve those issues.

    The files are app/controllers/FilesController.php and app/models/File.php. I am trying to make a new File in FilesController.php.


    Namespacing is pretty easy once you get that hang of it.

    Take the following example:

      app/models/File.php
    
    namespace App\Models;
    
        class File {
    
            public function someMethodThatGetsFiles()
            {
    
            }
        }
    

    app/controllers/FileController.php

    namespace App\Controllers;
    
    use App\Models\File;
    
    class FileController {
    
        public function someMethod()
        {
    
            $file = new File();
        }
    }
    

    By this way we can use namespaces in laravel 4.x

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: