I am unable to create a controller.
followed this step
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Hello World!';
}
}
?>
Saved the file to my application/controllers/blog.php
then it says
PAGE NOT FOUND
Issue was regarding naming of controller most tutorial suggested the controller file name coulb small but class name should Start with Capital
Here renaming the controller file-name with captial Blog solved the problem
Your issue is regarding the naming convention in Codeigniter. The naming convention is that, the name of the controller must be the same as the file name. It must also start with capital letter.So the name of your controller is Blog ,then the name of the file must be also Blog.php .
I hope this helps. ^_^
Related
Saving a model in a sub-folder such as models/cronjobs/Dbsconnection_model.php I always get a "Message: Unable to locate the model you have specified: Dbsconnection_model" error when i load it with
public function __construct()
{
parent::__construct();
require('application/config/CronJobs/CronjobsConfig.php');
**$this->load->model('cronjobs/dbsconnection_model');**
[......]
If i take the same model in the upper folder there are no troubles; in other words, this function
$this->load->model('dbsconnection_model');
does not trigger any error if the relative file is copied in the main models folder too. I tried also several combinations for the subfolder name:
cronjobs
Cronjobs
CronJobs
changing it both in the filesystem and in the loading function. Any ideas?
You need to capitalize the first letter of your model class and it will work.
So you can still call it like
$this->load->model('cronjobs/dbsconnection_model');
But the model file itself needs to start with a capital letter.
For example
application/models/cronjobs/Dbsconnection_model.php
I use CodeIgniter 3 with HMVC.
Does anyone know why do I get the following error
Severity: Notice
Message: Undefined property: Login::$login_model
On the second line below. I clearly call the model, but for some odd reason it is not linked properly
$this->load->model('auth/login_model');
$response = $this->login_model->attempt($username, sha1($password));
Then the model is pretty basic :
<?php
class Login_model extends CI_Model
{
public function attempt($user, $pass)
{
...
Now if I use an object it works, but I have the same issue in many places, including the place where I have
$this->db->select("....
where is crashing as there is no "db". What is the new solution for CodeIgniter 3? I've seen older posts, but none seem to help me out
Thanks!
just try this code put in controller:
public function __construct() {
parent::__construct();
$this->load->model('Login_model'); // load model
}
Problem is resolved, the issues were caused by the fact that my controller extended CI_Controller instead of MX_Controller. So changing
class Login extends CI_Controller
to
class Login extends MX_Controller
resolved the issue.
It took me a while to figure it out by debugging the thirdparty/MX/Loader.php, but once I saw it was looking for MX_Controller type I did the change and it worked perfectly.
This issue is one in many related to migration from CI 2 to CI 3 and also using the HMVC from Wiredesignz. Another big one is uppercase of file names and uppercase on the calls, so strictly referring to this issue I had to uppercase the calls in my controller (changed "login" to "Login"):
$this->load->model('auth/Login_model');
$response = $this->Login_model->attempt($username, sha1($password));
I did the above change already, so this was no longer a blocker, still I wanted to put it here just in case someone hits the exact same issue
Thanks all for your help
Today I have installed jeroennoten/laravel-adminlte and after following all the installation command I created a view and just wrote the line
#extends('adminlte::page')
and it works fine but I do not understand how it works? specially this :: symbol? I checked the laravel documentation but could not find anything.
Please help me by explaining it or give some article/tutorial link from where I can learn more.
adminlte is the name of the package, which is used for views and configs in Laravel as a namespace in order to avoid conflicts with other other packages.
It is defined in the ServiceProvider class on line 51.
By calling this in your blade files:
#extends('adminlte::page')
you are telling to Laravel, that you want to extend the page.blade.php file.
If you call #extends('page'), without adminlte::, it will look for the page.blade.php in your resources/views directory.
You won't see information in Laravel's Blade documentation section about this, because it's specific for Laravel Packages. And you can learn more from here.
::
symbol is a call of static function or static property in a class, for example if you define a class like this:
class Foo{
public static $a = 1;
public static function test(){};
}
you can use Foo::$a to get the value of $a, and use Foo::test() to call the function test().
i am new in programing laravel. so here I will not ask about my problems but I am here just want to ask how to use laravel. here I would like to ask how to use:
Determining If an Input Value Is Present in laravel. and what it does?
thanks ^^
Laravel is really a good MVC Framework.
I can suggest you some source from where you can get better understanding of Laravel Framework.
https://laravel.com/docs/5.2
https://laracasts.com/skills/laravel
For simple example - How to use Laravel after installation
Go to path using terminal ex. /var/www/laravel/project
Go to - /var/www/laravel/project/resources/views
Create a directory test and create a file index.php
Create a controller - php artisan make:controller TestController
Create a function testGet() and return view - return view('test.index'); //test is directory and index is file
Create a function testPost(Request $request) and to get data use $data = $request->all(); and then print this data.
Create a model with migration file - php artisan make:model Test --migration
Go to route file - /var/www/laravel/project/app/Http/routes.php
Add line Route::get('/test', 'TestController#testGet');
Add line Route::post('/test', 'TestController#testPost');
Now check GET request to your project http://project/test it will call testGet function.
POST request http://project/test?name=Adam will call testPost function and will print your name.
as said in the comments you better check laracasts! its the laravel school
anyway to anwser your question, its simple
View
<input type="text" name="fname">
Controller
public function doingstuff (Illuminate\Http\Request $request) {
if ($request->has('fname')) {
// a man gotta do what a man gotta do here
}
}
smooth huh? :3
I'm trying to extend the core AccountController.php -> app/code/core/Mage/Customer copied it to app/code/local/Mage/ and add a log to see which extends properly.
In the file AccountController.php (app/code/local/Mage/Customer/controllers)
...
...
public function createPostAction() {
Mage::log('In app/code/local/Mage/', null, 'test.log', true);
...
...
AND CORE (only test)
In the file AccountController.php (app/code/core/Mage/Customer/controllers)
...
...
public function createPostAction() {
Mage::log('In app/code/core/Mage/', null, 'test.log', true);
...
...
And does not go through code/local/ Mage but by CORE.
I need to configure something or it fails?
The logic through which controller class definitions are loaded builds the path to the file above the explicit include paths on which the autoloader relies. This means no local vs. core precedence.
You need to creat a controller rewrite by specifying a directory under the xpath frontend/routers/customer/args/modules/your_module
The latter node needs the before attribute set to Mage_Customer and you will need to create an AccountController.php with a createPostAction() method. Depending on your needs you may or may not need to extend from and require the core account controller class.
I guess you need to require the original controller:
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
Normally you need to do this with rewriting a controller the xml way...i havent checked in code, but maybe this is the problem.
I would recommend to do it the regular way via config.xml
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller