8.2.1 Using Core Class outside of main folder

Permalink
Hi,
I am trying to use the Concrete Core Classes to create a user outside of the main folder structure.

For example I had a main folder called

Project One
-- concrete
-- application
-- packages
... etc etc

and another folder called user-upload. In here I have an import-users.php script.

I have a single page which has a form with a file upload element. This takes a CSV and tries to send it to the import-users.php script ready to loop through and create a new user for each row in the CSV. but I keep getting the following error when trying to use the classes:

Fatal error: Class 'Core' not found in path/user_upload/import-users.php on line 6 Call Stack: 0.2009 254592 1. {main}() path/user_upload/import-users.php:0


How can I use the class outside of the concrete installation?? Examples would be extremely helpful

 
jero replied on at Permalink Reply
jero
I suspect it would be quite hard to do that and I'm curious why you would want to.

I'd be inclined to define a route to a controller which sits within concrete5's folders. I've done this a few times for loading users and it works just fine. Here's how I did it:

1) Add a route to application/config/app.php

return array(
      'routes' => array(
              '/ccm/import' => array('\Application\Controller\Import::view'),
     )
);


2) add a controller to application/controllers/import.php

<?php
namespace Application\Controller;
use Controller;
use Concrete\Core\User\UserInfo;
use Concrete\Core\User\Group\Group;
class Import extends Controller {
        public function view(){ ..add your import code here...}
}


You can then make your page post to index.php/ccm/import