• ( ! ) Fatal error: require(): Failed opening required ” (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php on line 265

    I get this above error despite trying so many suggestions in the forums, stackexchange etc.

    I developing a plugin in WordPress 4.0.1 using WP MVC, and it also encapsulates ORM concept that is in-built with WP MVC. I couldnt find a solution for this.
    Below is the code: (Admin Controller)

    /plugins/w2-store/app/controllers/admin/admin_geozone_rules_controller.php

    class AdminGeozoneRulesController extends AdminController {
    
        // Default items in Geozone Rules view
        var $default_columns = array(
                                    'id',
                                    'Geozone' => array('value_method' => 'admin_column_geozone'),
                                    'Country' => array('value_method' => 'admin_column_country'),
                                    'Zone' => array('value_method' => 'admin_column_zone'),
                                    'ordering');
    
        // Function to add a new record in wp_w2store_geozonerules table
        public function add() {
            $this->set_geozones();
            $this->set_countries();
            $this->set_zones();
            $this->set_geozonerules();
            $this->create_or_save();
        }
    
        public function edit() {
            $this->set_geozonerules();
            $this->set_geozones();
            $this->set_countries();
            $this->set_zones();
            $this->set_object();
            $this->verify_id_param();
            $this->create_or_save();
        }
    
        // Function to display the Country name Geozone Rules view
        public function admin_column_country($object) {
            return $object->country->country_name;
        }
    
        // Function to display the Geozone name Geozone Rules view
        public function admin_column_geozone($object) {
            return $object->geozone->geozone_name;
        }
    
        // Function to display the Zone name Geozone Rules view
        public function admin_column_zone($object) {
            return $object->zone->zone_name;
        }
    
        // Data retreived from four different tables using joins
        private function set_geozonerules() {
    
            $this->load_model('GeozoneRule');
            $geozonerules = $this->GeozoneRule->find(array(
                                                    'joins' => array(
                                                    'Geozone', 'Country', 'Zone'
                                                    ),
                                                    'includes' => array(
                                                    'Geozone', 'Country', 'Zone'
                                                    ),
                                                    'selects' => array(
                                                                    'Geozone.id', 'Geozone.geozone_name',
                                                                    'Country.id', 'Country.country_name',
                                                                    'Zone.id', 'Zone.zone_name',
                                                                    'GeozoneRule.id', 'GeozoneRule.ordering'
        /*                                                          ),
                                                    'conditions' => array(
                                                                        'GeozoneRule.geozone_id' => 'Geozone.id',
                                                                        'GeozoneRule.country_id' => 'Country.id',
                                                                        'GeozoneRule.zone_id'    => 'Zone.id'
        */                                                          )
                                                            )
                                                    );
    
            $this->set('geozonerules', $geozonerules);
        }
    
        private function set_geozones() {
            $this->load_model('Geozone');
            $geozones = $this->Geozone->find(array(
                                            'selects' => array(
                                            'id',
                                            'geozone_name'
                                            )
                                            ));
            $this->set('geozones', $geozones);
        }
    
        private function set_countries() {
            $this->load_model('Country');
            $countries = $this->Country->find(array(
                                            'selects' => array(
                                            'id',
                                            'country_name'
                                            )
                                            ));
            $this->set('countries', $countries);
        }
    
        private function set_zones() {
    
            $this->load_model('Zone');
            $zones = $this->Zone->find(array(
                                        'selects' => array(
                                        'id',
                                        'zone_name'
                                        )
                                        ));
            $this->set('zones', $zones);
        }   
    
        public function geozonerule_edit_link($object) {
            return empty($object->geozonerule) ? null
                                                : HtmlHelper::admin_object_link($object->geozonerule,
                                                    array('action' => 'edit'));
        }
    
        public function geozonerule_view_link($object) {
            return empty($object->geozonerule) ? null
                                                : HtmlHelper::admin_object_link($object->geozonerule,
                                                    array('action' => 'view'));
        }
    
    }
    
    ?>

    (Public Controller)

    /plugins/w2-store/app/controllers/geozone_rules_controller.php

    class GeozoneRulesController extends MvcPublicController {
    
        var $after = array('set_geozonerules');
    
            public function set_geozonerules() {
                $this->load_model('GeozoneRule');
                $geozonerules = $this->GeozoneRule->find();
                $this->set('geozonerules', $geozonerules);
            }
    
            // Overwrite the default index() method to include the 'is_public' => true condition
            public function index() {
    
            $objects = $this->GeozoneRule->find(array(
                                        'joins'     =>  array('Geozone', 'Country', 'Zone'),
                                        'includes'  =>  array('Geozone', 'Country', 'Zone'),
                                        'selects'   =>  array('Geozone.id, Geozone.geozone_name',
                                                        array('Country.id, Country.country_name',
                                                        array('Zone.id', 'Zone.zone_name',
                                                        array('GeozoneRule.id', 'GeozoneRule.ordering')
                                                        )
                                                )))
                                        );
            $this->set('objects', $objects);
    
            // pagination
            $this->params['page'] = empty($this->params['page']) ? 1 : $this->params['page'];
            $this->params['conditions'] = array('is_public' => true);
            $collection = $this->model->paginate($this->params);
            $this->set('objects', $collection['objects']);
            $this->set_pagination($collection);
    
            echo '<a href="admin.php?page=mvc_geozone_rules-add">Add New Geozone Rule</a>';
    
        }
    
        // GeozoneRule selects only GeozoneRule names and ids by default; to select all fields from GeozoneRule,
        // we'll overwrite the default show() method
        public function show() {
    
            $object = $this->model->find_by_id($this->params['id'], array(
                'includes' => array(
                                'Geozone',
                                'Country',
                                'Zone',
                                'GeozoneRule' => array(
                                                    'selects' => 'GeozoneRule.*'
                                                    )
                                )
                                ));
    
            if (!empty($object)) {
                $this->set('object', $object);
                $this->render_view('show', array('layout' => 'public'));
            }
        }
    }
    
    ?>

    Model:

    class GeozoneRule extends MvcModel {
    
        var $table = '{prefix}w2store_geozonerules';
        var $primary_key = 'id';
        var $display_field = 'id';
        var $default_order = 'sort_name';
        var $includes = array('Geozone', 'Country', 'Zone');
    
        var $has_and_belongs_to_many = array(
                            'GeozoneRule' => array(
                                            'join_table' => array('{prefix}w2store_geozones',
                                                                'fields' => array('id', 'geozone_name')),
                                                            array('{prefix}w2store_countries',
                                                                'fields' => array('id', 'country_name')),
                                                            array('{prefix}w2store_zones',
                                                                'fields' => array('id', 'zone_name')),
                                                                'fields' => array('id', 'ordering')
                                                                )
                                            );
    
        public function after_find($object) {
            if (isset($object->geozonerules)) {
                $geozonerule_names = array();
                foreach($object->geozonerules as $geozonerule) {
                    $geozonerule_names[] = $geozonerule->name;
                }
            }
    
        //  print_r ($object);
        //  exit;
        }
    
        public function after_save($object) {
            $this->update_sort_name($object);
        }
    
        public function update_sort_name($object) {
    
            $sort_name = $object->geozonerule_name;
            $this->update($object->__id, array('sort_name' => $sort_name));
        }
    
    }
    
    ?>

    Now the error i got:

    `Warning: require(): Filename cannot be empty in /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php
    on line 265 Call Stack Time Memory Function Location . . 11 0.0659 3870616 require( ‘/var/www/html/wordpress/wp-content/plugins/w2- . .

    Fatal error: require(): Failed opening required ” (include_path=’.:/usr/share/php:/usr/share/pear’) in
    /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php on line 265 Call Stack Time Memory Function Location . . 11 0.0659 3870616 require( ‘/var/www/html/wordpress/wp-content/plugins/w2-store/app/views/admin/layouts/admin.php’ ) ../mvc_controller.php:265 . .

    Any possible solutions will be of much help. Thanks a lot.

Viewing 1 replies (of 1 total)
  • Thread Starter Prabhu Bakiyaraj Chelladurai

    (@prabhuchelladurai)

    Issue solved. Simple error made a lot of fuss.

    In views/admin/ folder, there is a folder for the model GeozoneRule in the name ‘geozonerules’ and it was renamed to ‘geozone_rules’. Now it is ok.

    Naming of folders and files needs careful attention.

    Thanks folks.

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress Fatal error: require(): Failed opening required’ is closed to new replies.