Ich habe neues Plugin mit Informationen zu diesem Beitrag finden: https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/Klasse nicht gefunden, Plugin funktioniert gut
I composer.php aktualisieren und in Lieferanten Ordner habe ich Dateien erstellt Ich sehe Plugin phpclasses/evalmath in Backend.
Wenn auf Seite versuche ich mathematische Operation tun:
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)'));
}
Ich habe Fehler, die Klasse 'EvalMath' gefunden keine Klasse in der Datei definiert ist/plugins/phpclasses/evalmath/Verkäufer/phpclasses/evalmath/evalmath. class.php Was mache ich falsch?
in Datei /plugins/phpclasses/evalmath/composer.json
{
"require": {
"phpclasses/evalmath": ">=1.0.0"
},
"repositories": [
{
"type": "composer",
"url": "https:\/\/www.phpclasses.org\/"
},
{
"packagist": false
}
]
}
in Datei /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 [email protected]
*/
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 der Datei/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' => [
],
],
];
innerhalb '/ plugins/phpclasses/evalmath /' haben Sie eine Klasse namens 'EvalMath'? –
füge nach Namespace hinzu phpclasses \ EvalMath in Plugin.php –
Ich habe mich jetzt von Php namespace phpclasses \ evalmath; zu php namespace Phpclasses \ EvalMath; aber immer noch nicht erkennen Klasse – Casa