Files in the lib directory

  • The heart of your application lives in the lib directory.
  • This directory contains a file called MyApp.pm. This file defines the namespace and inheritance that are necessary to make this a Catalyst application. It also contains the list of plugins to load application-specific configurations. These configurations can also be defined in the myapp.conf file mentioned previously. However, if the same configuration is mentioned in both the files, then the configuration mentioned here takes precedence.
  • Inside the lib directory, there are three key directories, namely MyApp/Controller, MyApp/Model, and MyApp/View. Catalyst loads the Controllers, Models, and Views from these directories respectively.

Right now, there's one Controller called Root.pm. This will handle all root level (/) URLs. This is where the code that generates the welcome page is located.

Keep in mind that MyApp is just like any other namespace of a module. The application is created with whatever you passed as an argument to catalyst.pl when you created the application. Just like any other module, a namespace with double colons corresponds to subdirectories in the filesystem. For example, catalyst.pl MyCompany::HR::Timeslips would create the application with the namespace MyCompany::HR::Timeslips. Therefore, it will be represented in the filesystem as MyCompany/HR/ Timeslips.pm as the application is created within the lib directory when using catalyst.pl. The path on the filesystem from the root of your catalyst application will be lib/MyCompany/HR/ Timeslips.pm. Similarly, the other files/directories that are created will be lib/MyCompany/HR/Timeslips/Controller/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.117.212