Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Need to implement PHPSpellChecker with FuelPHP...
  • I'm new to FuelPHP and need to implement PHPSpellChecker Class. I can't find any help related to its implementation with FuelPHP. I'm trying it out by creating a package but I'm not sure how to proceed. : (

    Please help me out and guide me what steps I should follow.

    Thanks in Advance : )
  • Copy it to app/vendor, and run the include as stated in the documentation?
  • Thanks Harro : )

    It helped me to some extent I can use some feature by adding PhpSpellChecker folder within vendor.

    But I'm still facing some issues related to path for installation..

    Please refer to code below:

    require_once(APPPATH.'vendor/phpspellcheck/include.php')  ;

    $mySpell = new SpellAsYouType();
        $mySpell->CaseSensitive = true;
        $mySpell->CheckGrammar = true;
        $mySpell->CheckInSitu = false;
        $mySpell->Fields = "ALL";
        $mySpell->FormToSubmit="form1";
        $mySpell->IgnoreAllCaps = true;
        $mySpell->IgnoreNumeric = true;
        $mySpell->InstallationPath = '';    ( Relative URL of phpspellcheck within your site )
        $mySpell->Language = "English (International)";
        $mySpell->UserInterfaceLanguage="en";
        $mySpell->CSSTheme= "classic";
        $mySpell->SettingsFile = "default-settings";
        $mySpell->Strict = true;
        $mySpell->Delay = 300;
        echo $mySpell->Activate();


    $mySpell->InstallationPath:
    is used to call a js file which is placed within the phpspellcheck folder in vendor.
    If you have gone through it you can find it contains core folder where index file is placed and to access this file also it uses the same installation path.. and other related files are also getting called up using this path.. making it a bit more difficult for me to handle.

    Is there a way to use js inside vendor folder??? What will be the relative path in that case??

    Thanks in Advance : )



  • HarroHarro
    Accepted Answer
    In a standard FuelPHP installation all code is outside the DOCROOT (for security reasons), client-side files (js, css, images, etc) can not be stored with the code, they have to be in the public folder.

    So either move the js files (to for example /public/assets/phpspellcheck) or create a controller for that loads and returns them, then use routes to route the requests for those files to that controller.

    The first option is a lot easier, the second will allow you to update the phpspellcheck code without having to update your public files again.

    Public URI paths are relative to public, so anything in the /public/assets/ folder can be accessed via http://yourhostname/assets/...
  • Thanks again Harro for your guidance : )

    But since it is using a common installation path variable for js as well as php file it is becoming difficult for me to manage, I'm trying the first option you suggested, hope will reach to a solution.

    Regards,
    Khushboo
  • Thanks Harro for your help I successfully implemented PHPSpellCheck with FuelPHP:

    Place the phpspellcheck folder within asset->js folder.

    And then in my view I used this code provided by PhpSpellcheck:

    require_once(DOCROOT.'assets/js/phpspellcheck/include.php')  ;

    $spellcheckObject = new PHPSpellCheck();
    $spellcheckObject->LicenceKey = "TRIAL";
    $spellcheckObject->DictionaryPath = (DOCROOT."/assets/js/phpspellcheck/dictionaries/");
    $spellcheckObject->LoadDictionary("English (International)") ;  //OPTIONAL//
    //$spellcheckObject->LoadCustomDictionary("custom.txt");
    $spellcheckObject->AddCustomDictionaryFromArray($title);
    $spelledItRight = $spellcheckObject->SpellCheckWord($word);
    if(!$spelledItRight){
        $suggestions = $spellcheckObject->Suggestions($word);
        $results = array_intersect($suggestions, $title);
        if (is_array($results))
        {
            /*Your code comes here*/
        }
       
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion