Config helper in Laravel - php

We have this existing project need to do maintenance and it is written in Laravel and so I am forced to learn since my base is CodeIgniter. So I came across this line
echo config('global.header_title')
from view which I believe a helper from config. Based on the doc here https://laravel.com/docs/7.x/configuration#accessing-configuration-values if you are echoing something like config('global.header_title') it means that, the source is
config folder > global.php file > header_title variable (inside the array)
So I've been searching this global.php within the config folder but it is nowhere to be found. I was wondering if this is a helper or something else. Or maybe it's a helper but stored somewhere. But can a helper be stored at a different folder other than config?

Related

laravel 4 create module and put controller , module and view inside module

I have worked on yii framework before and I had possibility to create module folder and inside this put eg: news module which was included controllers, views and module
I'm new in laravel and trying to create same thing MODULE
i tried the following inside routing
Route::get('/news','/modules/news/controllers/NewsController#index');
file exist but i'm getting
ReflectionException
Class /modules/news/controllers/NewsController does not exist
why ? what i'm doing wrong ?
The Route::get() function is looking for a (auto)loaded Class, not for a file on the disk to load, which is why you're getting these errors.
It's more Laravely (Laravelish?) to include:
Controllers in the /app/controllers/ directory
Views in /app/views/ directory
Models in the /app/models/ directory
And if you are starting out with Laravel, this might be the best way to get started. The autoloader knows where to look for your classes then, and everything gets handled automatically for you.
With the NewsController situated in /app/controllers/ you can do this:
// no need to start the route location with a slash:
Route::get('news', array('uses' => 'NewsController#index'));
You can "package" up functionality using Laravel's Packages, but it would be better to check out the excellent docs and then come back with specific questions..
Put your Laravel controllers in app/controllers, since that directory gets autoloaded, and it is where Laravel expects controllers to be.
Then you can use routes like this (example straight from the docs at http://laravel.com/docs/controllers#basic-controllers)
Route::get('user/{id}', 'UserController#showProfile');

Loading Config and Setting a Config Value in CodeIgniter

I try to create application with back-end and frond-end. The folder structure as follows(only show config file position to explain problem)
+root
|-admin
|-application
|—backend
|—config
|—config.php
|—frontend
|—config
|—config.php
|-system
Using back-end admin panel I try to change config value in both back-end and frond-end config.php value. But I fail to change it in front-end config.php file. I don’t need database based solution for this.
Reading the documentation I got this:
Note: CodeIgniter always tries to load the configuration files for the current environment first. If the file does not exist, the global config file (i.e., the one in application/config/) is loaded. This means you are not obligated to place all of your configuration files in an environment folder − only the files that change per environment.
So based on that information, I think the problem is when you are calling it, maybe a problem with your path.

config codeigniter to run first project

I am using xampp and my document root in apache is set to htdocs directory by default. I download Codeigniter and unzip the project into this directory. It runs fine. Now I would like to use CI to create my own project. In the controllers folder I would like to create a folder named “myproject” and in the views folder of application folder, I would like to create a folder named “myproject_view” in which I will store all of my view files. My problem is I don’t know how to reset my config file (especially the route.php) for my project to work then.
CodeIgniter documentation doesn’t have a section to specify how to do this, the information given in URI Routing chapter is not enough for readers to understand this at all. Plus, What if I also would like to store my controler files in a nested folder (controllers > somefolder > someanotherfolders > etc) ? Thank you very much.
[UPDATE]
If you only leave all controller in controllers folder, and view files in the views folder, then things work out easily, what if you create a folder in teh controllers and a folder for view in the views folder. I guess you need to change your default route configuration. I would like to know HOW ?
CodeIgniter's documentation covers Sub-Folders for Controllers.
Views on the other hand, are always loaded from controllers. Therefore, you can write:
$this->load->view('my_folder_name/my_view');
Routes are not required here.

In which folder to place the classes that I extend in the Kohana 3.1 framework?

I am new to the kohana php framework. In the modules folder in kohana 3.1, there are many empty files extending the existing classes. Should I write my code in those empty files?
If yes, do I have to make any changes in bootstrap?
If not, where should I place these files? Should they be in a subfolder inside the Application directory or inside the modules directory?
Which all files will I have to copy from the modules to application?
Those empty files you see are aliases created for the class. An example would be the Cookie class, declared as so:
class Cookie extends Kohana_Cookie {}
It's just another way for you to refer to the real class, in this case Kohana_Cookie, without having to type all that out.
So when you use something like Cookie::salt($name, $value) you're really just using Kohana_Cookie::salt($name, $value).
If you want to extend a class, you can drop the files into your application/classes folder and go from there.
check out the docs at http://kohanaframework.org/3.1/guide
especially: http://kohanaframework.org/3.1/guide/kohana/files
you can extend classes in the folder: application/classes/.. or modules//classes/..

PHP: Storing objects in a Symfony plug-in module's lib/ directory

I am building a Symfony project, and have created a new plug-in named sfUtilsPlugin. I currently have a directory structure that looks like this:
sfUtilsPlugin/
modules/
sfSearchLucene/
actions/
config/
lib/
templates/
Now, in the sfUtilsPlugin/modules/sfSearchLucene/lib directory, I have an object called sfLucene. The idea was that this object is accessible from the Symfony auto loading mechanism, so that it can be instantiated from anywhere within the application.
However, simply adding the sfLucene.class.php file to the sfUtilsPlugin/modules/sfSearchLucene/lib directory does not appear to add it to the autoloader.
Does anyone out there know why this might be happening? Perhaps it is just not possible to automatically use objects stored in this location inside Symfony.
Any advice is appreciated.
Because you are adding this class in lib subdirectory of module sfLucene, it will be autoloaded only if current module is sfLucene.
You have two options:
put this class somewhere into sfUtilsPlugin/lib directory;
require them every time you need it

Categories