Loading a Facebook plugin and config application for CakePHP - php

I am new to CakePHP, but I've started using CakePHP 2.0. Unfortunately my host has PHP 5.2.6 and CakePHP 2 won't run. I want to add a Facebook plugin to my CakePHP 1.3 application. I downloaded the plugin into the app\plugins\facebook folder and copied facebook.php from app\plugins\facebook\config\facebook.php to app\config\facebook.php
class AppController extends AppController {
var $helpers = array('Facebook.Facebook');
}
It is reporting missing facebook helper app\views\helpers\facebook.php
<?php CakePlugin::load('Facebook'); ?> //in bootstrap.php is giving an error
Is there anything I would have done in bootstrap.php to cause this and how might I fix it?

All you need to do Enable the plugin in app/Config/bootstrap.php , You also need to add your appID and AppSecret.
For Details you can see the configuration in following link
https://github.com/Pollenizer/CakePHP-Facebook-Plugin
Hope it works for you.

Related

hmvc in codeigniter cannot access modules

Iam trying to switch to hmvc in codeigniter. I will explain my issue from scratch itself. First I downloaded Codeignter 3.0 version from http://www.codeigniter.com/download and when I check my browser it is showing the welcome message of CI. Now to add hmvc structure I downloaded the hmvc modular extension from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads. And placed the core and third party modules inside my CI folder. Then I created a Folder inside the application folder and named it as modules. Within modules I created a folder say test. I have a controller folder which contain test.php.
class Test extends MY_Controller {
public function index()
{
echo "hey my first module is ready";
}
}
But when i call the module in the url like localhost/index.php/test i got a page not found error. Am i missing any configuration? I got all other controller working well before i switched to hmvc. How can i fix this. Thanks in advance.
Do you forget this piece of code in your config file?
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
);
Do you created your own Controller? Cause you extends MY_Controller.
If not, extend CI_Controller or MX_Controller
For more information read the documentation at wiredesignz's HMVC for Codeigniter
Kind regards
Try to follow this tutorial.Here you will get ready to use HMVC folder. http://www.darwinbiler.com/ready-to-use-codeigniter-modular-extensions-hmvc/

Codeigniter 3 dev Unable to load the requested class

I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?
As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html
By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');

CodeIgniter Modular Extensions & the i18n library

I have been using the CodeIgniter i18n library by Jérôme Jaglale (http://maestric.com/en/doc/php/codeigniter_i18n), which works great for my project.
But since I need to write separate modules, I recently added CodeIgniter Modular Extensions ( https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc ) and the navigation breaks.
How can I solve this issue please, I would love to use both the i18n library & Modular Extensions.
I think my application navigation fails to work because i18n library introduces adds a language segment in the site url, in my case my url is localhost/index.php/en/home and after adding Modular Extensions, my navigation/links stop working.
Thank you in advance.
Recently, I try to use HMVC with i18n and have similar problem. Below is my solution.
1.first you need to go to here HMVC select "Branches" to download HMVC extension, don't download the one on github it might not work.
2.Unzip HMVC extension inside the folder copy two files "MY_Loader.php" and "MY_Router.php" from core folder to Codeigniter's "application/core" after that copy "MX" folder from "third_party" to Codeigniter's "application/third_party". By this point your HMVC is installed, however it will not work because i18n cause the problem so if you run your website it might not display.
3.You need to get new version of i18n which support both HMVC and none HMVC, the old version of i18n seems not support HMVC. Go to here i18n download it and take time to read the description on github.
4.Before this step I suggest you to backup "application/core/MY_Config.php" and "application/core/MY_Lang.php" in case something goes wrong you can reverst back. Unzip i18n inside folder copy file "language.php" from config folder to Codeigniter's "application/config", copy two files "MY_Config.php" and "MY_Lang.php" from core folder to Codeigniter's "application/core", finally copy "MY_language_helper.php" from helpers folder to Codeigniter's "application/helpers". So far you have new i18n installed, but you need to configure it to make it work, otherwise you might get error message.
5.Open "application/core/MY_Config.php" and replace the line require_once APPPATH . "libraries/MX/Config.php"; to require_once APPPATH . "third_party/MX/Config.php"; then open "application/core/MY_Lang.php" replace the line require APPPATH . "libraries/MX/Lang.php"; to require APPPATH . "third_party/MX/Lang.php";. Why? because it point to the wrong directory, the MX folder is located in "third_party" not "libraries" in case you don't know, if you don't change it you might get error message.
6.To add new language(Not create language file) you need to open "application/config/language.php". You see at top the code block with comment says "Supported Languages" there already have English and Russian language configure for you just need to copy the template and change to the language you want, it's very easy. Be aware folder's name must exactly the same as folder in "application/language".
7.According to i18n github description you need to add these line
$route['^(en|de|fr|nl)/(.+)$'] = "$2";
$route['^(en|de|fr|nl)$'] = $route['default_controller'];
to the "application/config/routes.php". Be aware this line $route['^(en|de|fr|nl)/(.+)$'] = "$2"; in old i18n probably is $route['^(en|de|fr|nl)/(.+)$'] = "$1"; the difference is "$1" have to change to "$2", otherwise you will got problem.
8.To create language file is same as the method you did in old i18n. Now test your website with multi-language to make sure everything work fine.
9.Create your module. How? Create a folder name "modules" inside Codeigniter's application folder, inside modules folder you can start to create your module. That's say you want to create a module call foo, you just need to create a folder name it "foo" and then inside foo folder you can create three folders controllers, models and views. Create a php file with name foo with the code below
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Foo extends MX_Controller
{
public function index()
{
echo "<h1>class foo this is module test</h1>";
}
}
Enter url to run your module, if you see "class foo this is module test" then it work.
Remember module class must extends from MX_Controller.
If you still encounter any problem just ask.

CakePHP TwigView Plugin Missing View Error

I am using CakePHP 2.4.2 and this plugin by predominant.
I want to use TwigView with CakePHP and found that the plugin above is compatible with CakePHP 2.0. Followed all the installation steps, however, getting the Missing View error while executing the script.
My AppController.php
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $viewClass = 'TwigView.Twig';
}
The view's extention is .tpl, however, even after adding the Plugin it is still looking for .ctp extention.
I have also loaded the plugin in bootstrap.php using
CakePlugin::load('TwigView');
define('TWIG_VIEW_CACHE', APP . 'tmp');
Any Idea what could go wrong.
http://api.cakephp.org/2.4/source-class-Controller.html#209-214
Set the Controller::$ext property in your app controller to "tpl" and your're done.
Searching before asking is also always a good idea, see CakePHP View change extension

Symfony 1.4 don't load sfFormExtraPlugin on production server

I have a site built in symfony 1.4. In the develop machine everything works ok, but when upload to production machine, plugins stop to load.
This is my project conf:
require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->setWebDir($this->getRootDir().'/public_html');
$this->enablePlugins('sfDoctrinePlugin');
$this->enablePlugins('sfFormExtraPlugin');
$this->enablePlugins('sfDoctrineGuardPlugin');
$this->enablePlugins('bootstrapAdminThemePlugin');
}
}
I can see the js files loaded, for example: tiny_mce.js. But my textarea does not become text editor. Same thing with dates and autocompletes.
I have the same code in both servers.
Please any help?
Thank you.
What is the actual issue ? symfony Modules or JS files not loaded ?
Maybe you forgot to publish the plugin assets ?
Have you tried
php symfony plugin:publish-assets

Categories