This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

d1i1n1
d1i1n1

I made new plugin with informations find at this post: https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/

I update composer.php and in vendor folder i got created files I see plugin phpclasses/evalmath in backend.

When on page i try do math operation:

function onStart() {

// instantiate a new EvalMath

    $m = new EvalMath;

        $m->suppress_errors = true;

            // set the value of x

                $m->evaluate('x = 3');

     var_dump($m->evaluate('y = (x > 5)'));

}

I got error that Class 'EvalMath' not found Class is defined in file /plugins/phpclasses/evalmath/vendor/phpclasses/evalmath/evalmath.class.php What i am doing wrong?

in file /plugins/phpclasses/evalmath/composer.json

{

  "require":

      {

            "phpclasses/evalmath": ">=1.0.0"

              },

                  "repositories":

                  [

                    {

                      "type": "composer",

                      "url": "https:\/\/www.phpclasses.org\/"

                    },

                    {

                      "packagist": false

            }

      ]

}

in file /plugins/phpclasses/evalmath/Plugin.php

<?php namespace phpclasses\evalmath;

use App; use Config; use System\Classes\PluginBase; use Illuminate\Foundation\AliasLoader;

/**

  • Class Plugin */ class Plugin extends PluginBase { /**

    • Returns information about this plugin.
    • @return array */ public function pluginDetails() { return [ 'name' => 'phpclasses/evalmath',

      'description' => 'OctoberCMS plugin for demonstrating the use of Laravel Packages within October plugins',
      
      'author'      => 'hhh',
      
      'icon'        => 'icon-leaf'

      ]; }

    /**

    • Runs right before the request route */ public function boot() {
      // Setup required packages $this->bootPackages(); }

    /**

    • Boots (configures and registers) any packages found within this plugin's packages.load configuration value
    • @see https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-plugins
    • @author Luke Towers octobercms@luketowers.ca */ public function bootPackages() { // Get the namespace of the current plugin to use in accessing the Config of the plugin $pluginNamespace = str_replace('\', '.', strtolower(NAMESPACE));

      // Instantiate the AliasLoader for any aliases that will be loaded
      $aliasLoader = AliasLoader::getInstance();
      
          // Get the packages to boot
          $packages = Config::get($pluginNamespace . '::packages');
      
              // Boot each package
              foreach ($packages as $name => $options) {
                      // Setup the configuration for the package, pulling from this plugin's config
                      if (!empty($options['config']) && !empty($options['config_namespace'])) {
                              Config::set($options['config_namespace'], $options['config']);
                          }
      
                          // Register any Service Providers for the package
                          if (!empty($options['providers'])) {
                              foreach ($options['providers'] as $provider) {
                                  App::register($provider);
                              }
                          }
      
                          // Register any Aliases for the package
                          if (!empty($options['aliases'])) {
                              foreach ($options['aliases'] as $alias => $path) {
                                  $aliasLoader->alias($alias, $path);
                  }
          }

      } } }

in file /plugins/phpclasses/evalmath/classes/config.php

<?php return [

// This contains the Laravel Packages that you want this plugin to utilize listed under their package identifiers
'packages' => [

    'phpclasses/evalmath' => [

    ],

],

];

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.