Unable to locate the model you have specified codeigniter-3.1.10 - codeigniter-3

An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: My_model
Filename: C:\xampp\htdocs\Domain_monitoring\system\core\Loader.php
Line Number: 348
Declare on my controller
$this->load->model('my_model');
Declare in model
class My_model extends CI_Model {
function __construct()
{
parent::__construct();
}
File name of model My_model.php

Related

CodeIgniter 3.x.x + WireDesignz HMVC - Call to a member function core_template() on null

I downloaded HMVC files from here and set up my CI 3 installation using these file
Place the MX folder in application/third_party folder
Place the files in application/core MY_Loader & MY_Router
Created a folder module in /application.
Inside module created welcome/controller and welcome/view
In welcome/controller I copied the default welcome controller and in
welcome/view welcome_message.
Then I created a Template Module with and added below code in it
Then I created module for home, here is how my folder structure looks like
class Template extends MY_Controller {
public function __contruct(){
parent:: __contruct();
}
public function core_template($data = null)
{
//$data = new stdClass();
//$data->content = 'home/home_v';
$this->load->view('template/core_template_v', $data);
}
public function dashboard_template($data = '')
{
//$data = new stdClass();
$this->load->view('template/dashboard_template_v', $data);
}
}
Folder Structure
application
modules
template
controllers
Template.php
models
views
core_template_v.php
Home
controllers
Home.php
models
views
home_v.php
Home.php // Controller
class Home extends MY_Controller {
public function __construct(){
parent::__construct();
$this->load->module('Template');
}
public function index()
{
$data = new stdClass();
$data->content = 'home/home_v';
//$this->slice->view('welcome/welcome', $data);
//print_r($data);
$this->template->core_template($data);
}
}
============================================
/* load the MX_Controller class */
require APPPATH."third_party/MX/Controller.php";
class MY_Controller extends MX_Controller {
public function __construct(){
parent::__construct();
$this->load->module('Template');
}
}
I am getting this error:
An uncaught Exception was encountered
Type: Error
Message: Call to a member function core_template() on null
Filename: */modules/home/controllers/Home.php
Line Number: 18
Backtrace:
File: /*/public_html/index.php
Line: 315
Function: require_once
It is working perfectly fine on my local server but when I upload the code to my hosting its throwing this error.

Segmentation error in Vala

Please, tell me what the problem is. After receiving the input field from the Glade file and attempting to use it, a segmentation error is caused.
namespace MyApp {
class MyAppClass : Object {
Entry myAppEntry;
public MyAppClass () {
Builder builder = new Builder.from_file("myApp.ui");
myAppEntry = builder.get_object("myAppEntry") as Entry;
}
public void button_click(){
stdout.write(myAppEntry.get_text().data); //There is a segmentation error
}
}
}

hmvc load controller Cannot redeclare class CI

i developed an CMS in codeigniter 2 with HMVC and now im trying to migrate to Codeigniter 3. I have the follow issue.
This works in view codeigniter 2
<?PHP $configuracion = $this->load->controller('configuracion/todos');
?>
I recive the error: Fatal error: Cannot redeclare class CI in /home/xxxx/public_html/application/third_party/MX/Base.php on line 57
This is the controller:
<?php
class Configuracion extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->model('configuracion_m', 'Configuracion_m');
}
function todos() {
return $this->Configuracion_m->get_all();
}
Thanx!!!!!

Prism and Simple Injector

I'm trying a simple HelloWorld using simple inject and prism.
Git Source
When application starts, this error come up
Failed to assign to property
'Prism.Windows.Mvvm.ViewModelLocator.AutoWireViewModel'. [Line: 8
Position: 5]"
Exception thrown: 'System.MissingMethodException' in Prism.Windows.dll
Exception thrown: 'Windows.UI.Xaml.Markup.XamlParseException' in
HelloWorldPrism.exe WinRT information: Failed to assign to property
'Prism.Windows.Mvvm.ViewModelLocator.AutoWireViewModel'. [Line: 8
Position: 5] An exception of type
'Windows.UI.Xaml.Markup.XamlParseException' occurred in
HelloWorldPrism.exe but was not handled in user code WinRT
information: Failed to assign to property
'Prism.Windows.Mvvm.ViewModelLocator.AutoWireViewModel'. [Line: 8
Position: 5] Additional information: The text associated with this
error code could not be found. Failed to assign to property
'Prism.Windows.Mvvm.ViewModelLocator.AutoWireViewModel'. [Line: 8
Position: 5]
e.StackTrace " at Windows.UI.Xaml.Application.LoadComponent(Object
component, Uri resourceLocator, ComponentResourceLocation
componentResourceLocation)\r\n at
HelloWorldPrism.Views.MainView.InitializeComponent()\r\n at
HelloWorldPrism.Views.MainView..ctor()" string
<Page
x:Class="HelloWorldPrism.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mvvm="using:Prism.Windows.Mvvm"
mvvm:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
>
public MainViewModel(INavigationService navigationService)
{
_navigationService = navigationService;
}
If I add a parameterless constructor it works normal.
public MainViewModel()
{
}
App.cs
protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
{
Window.Current.Activate();
return Task.FromResult(true);
}
protected override void CreateAndConfigureContainer()
{
Logger.Log("Creating and Configuring Container", Category.Debug, Priority.Low);
Container = CreateContainer();
}
protected override Container CreateContainer()
{
return new Container();
}
protected override UIElement CreateShell(Frame rootFrame)
{
var shell = Container.GetInstance<MainView>();
shell.SetFrame(rootFrame);
return shell;
}
protected override Type GetPageType(string pageToken)
{
var type = Type.GetType(string.Format(CultureInfo.InvariantCulture, GetType().AssemblyQualifiedName.Replace(GetType().FullName, GetType().Namespace + ".Views.{0}View"), pageToken));
if (type != null)
return type;
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, ResourceLoader.GetForCurrentView("/Prism.Windows/Resources/").GetString("DefaultPageTypeLookupErrorMessage"), pageToken, GetType().Namespace + ".Views"), nameof(pageToken));
}
protected override Task OnInitializeAsync(IActivatedEventArgs args)
{
Container.RegisterSingleton(SessionStateService);
Container.RegisterSingleton(DeviceGestureService);
Container.RegisterSingleton(NavigationService);
Container.RegisterSingleton(EventAggregator);
return Task.CompletedTask;
}
protected override void ConfigureViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => new
SimpleInjectorServiceLocatorAdapter(Container));
}
When application starts, this error come up
In the MainView.xaml, you defined the AutoWireViewModel property to true. Once this property is set to True, the ViewModelLocator will try to instantiate the corresponding ViewModel based on a particular convention. Since the names of your View and ViewModel met the convention, when you set this property to true, Prism will help you instantiate the corresponding ViewModel.
Inside Prism.mvvm namespace, the ViewModelLocationProvider class locates the view model for the view that has the AutoWireViewModelChangedattached property set to true. And the error is thrown by the following code line of ViewModelLocationProvider class:
/// <summary>
/// The default view model factory which provides the ViewModel type as a parameter.
/// </summary>
static Func<Type, object> _defaultViewModelFactory = type => Activator.CreateInstance(type);
System.MissingMethodException: 'No parameterless constructor defined for this object.'
So it is caused by the Activator.CreateInstance(Type) method requires a public constructor, please see MissingMethodException.
If I add a parameterless constructor it works normal.
It seems like this is the correct solution. If you just don't want a parameterless constructor for the ViewModel, you may try instantiate it and set the DataContext to the View by yourself. If you doubt this is an issue for Prism library maybe you can open a thread here.
Update:
According to #rubStackOverflow, it was missing ViewModelLocationProvider.SetDefaultViewModelFactory((viewMo‌​delType) => Container.GetInstance(viewModelType)); on OnInitializeAsync method.

Zend frame work Custom view helper error

Hi am trying to add custom helper throughout my application
Have done following steps
index.php
$view = new Zend_View();
$view->addHelperPath('My/View/Helper', 'My_View_Helper');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
Helper class in My/View/Helper
class My_View_Helper_Common extends Zend_View_Helper_Abstract
{
public function example()
{
return "ok";
}
}
now calling in view index.phtml
$this->example()
am getting this error
Uncaught exception 'Zend_View_Exception' with message 'script 'error/error.phtml' not found in path (.\application\views\scripts\)' in C:\xampp\htdocs\wyfixture\library\Zend\View\Abstract.php:924
Stack trace:
#0 C:\xampp\htdocs\wyfixture\library\Zend\View\Abstract.php(827): Zend_View_Abstract->_script('error/error.pht...')
#1 C:\xampp\htdocs\wyfixture\library\Zend\Controller\Action\Helper\ViewRenderer.php(903): Zend_View_Abstract->render('error/error.pht...')
#2 C:\xampp\htdocs\wyfixture\library\Zend\Controller\Action\Helper\ViewRenderer.php(924): Zend_Controller_Action_Helper_ViewRenderer->renderScript('error/error.pht...', NULL)
#3 C:\xampp\htdocs\wyfixture\library\Zend\Controller\Action\Helper\ViewRenderer.php(963): Zend_Controller_Action_Helper_ViewRenderer->render()
#4 C:\xampp\htdocs\wyfixture\library\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 C:\xampp\htdocs\wyfixture\library\Zend\Controller\Action.php(523):
please help me
In addition to Vikas answer.
To call more than one method in a view helper you can use code like this:
In My/View/Helper/Example.php
class My_View_Helper_Example extends Zend_View_Helper_Abstract
{
public function example()
{
return $this;
}
public function foo()
{
return 'foo';
}
public function bar()
{
return 'bar';
}
public function __toString()
{
return $this->foo();
}
}
In you views:
echo $this->example()->foo() // prints foo
echo $this->example()->bar() // prints bar
echo $this->example() // prints foo
Seems like you have two problems here:
Your 'application/views/scripts/error/error.phtml' is missing. You can restore it and you'll get more accurate exception message at once.
Your helper class should contain a method named after the helper.
So, in your case it's file My/View/Helper/Example.php with the following body
class My_View_Helper_Example extends Zend_View_Helper_Abstract {
public function example() {...}
}
Then you'll be able to call it from the view with
$this->example()