catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

Fatal error: Class 'Medoo\Medoo' not found in Medoo-master\test.php on line 11 #737

Closed sl5net closed 6 years ago

sl5net commented 6 years ago

first error was: Fatal error: Class 'Medoo\Medoo' not found in Medoo-master\test.php on line 11

<?php require 'vendor/autoload.php'; use Medoo\Medoo;

i changed to use src\Medoo;

next error is: Parse error: syntax error, unexpected '$database' (T_VARIABLE) in E:\fre\private\HtmlDevelop\AutoHotKey\global-IntelliSense-everywhere-Nightly-Build\Source\plugins\php\phpdesktop\www\Medoo-master\test.php on line 21

thats this line: $file = "someDB.db" $database = new Medoo([ 'database_type' => 'sqlite', 'database_file' => $file, ]);

FahriDevZ commented 6 years ago

You need to import the class If you installed via composer, just use this code to requrie autoloader on the top of your projects like this:

require 'vendor/autoload.php';

// Using Medoo namespace
use Medoo\Medoo;

If not using the composer. Just download medoo.php and put it into the right directory and then require

require  'Medoo.php';

// Using Medoo namespace
use Medoo\Medoo;

For reference, see https://medoo.in/api/new

sl5net commented 6 years ago

thanks but that i did first. composer created the vendor folder. but no Medoo folder. i renamed to src inside the source file

i will try as soon i will back home again

catfan commented 6 years ago

@Fahri5567 is right. That's namespace problem. Or read the initialization guide https://medoo.in/api/new.

sl5net commented 6 years ago

thanks all. and sorry that i am beeing so late.

the errors from the beginning are solved. now i have problem with

$file = "someDB.db" $database = new Medoo([ 'database_type' => 'sqlite', 'database_file' => $file, ]);

probably becouse i have no someDB.db there.

i searche a little.

is there a Medoo for creating a sqliteDb? or easy bestParctice workaround? thanks