0

Summary:
I'm a web and backend newb, but basically I've inherited a CakePHP project and I'm trying to set up a dev environment. I'm trying to display my project-level src directory at http://localhost/backend/, which autoroutes to http://localhost/backend/admin/users/dashboard, but it only loads PROJECT_ROOT/vendor/maiconpinto/cakephp-adminlte-theme/src.

Question:
How do I load my own sidebar using my top-level src directory? Thanks in advance!
Here's the desired sidebar: correct myteamconnector sidebar
Here's the sidebar that is getting loaded: incorrect vendor files sidebar

Setup Info:
System: Mac OS 10.14 Dev Apps:

  • AMPPS v3.8
  • Apache v2.4.27
  • PHP v7.1
  • MySQL v5.6.37
  • CakePHP v3.5.17

PROJECT_ROOT/index.php:

require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';

PROJECT_ROOT/webroot/index.php:

// Check platform requirements
require dirname(__DIR__) . '/config/requirements.php';

// For built-in server
if (php_sapi_name() === 'cli-server') {
    $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);

    $url = parse_url(urldecode($_SERVER['REQUEST_URI']));
    $file = __DIR__ . $url['path'];
    if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
        return false;
    }
}
require dirname(__DIR__) . '/vendor/autoload.php';

use App\Application;
use Cake\Http\Server;

// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));

// Run the request/response through the application and emit the response.
$server->emit($server->run());
Pete
  • 1
  • 3
  • Your first problem is that you don't actually want to load the `src` folder. The `webroot` folder should have an `index.php` in it, which takes care of everything you need to correctly reference the implementation that's found in `src`. In other words, point your web server's "document root" at the `webroot` folder, and you should be well on your way. – Greg Schmidt Feb 15 '19 at 05:56
  • Hmm. That makes sense. Thanks for the reply. I added the contents of `index.php` and `webroot/index.php` to my post. The line about binding my application points to my `config` directory, so not sure what I would change, but I'm obviously still missing something important. – Pete Feb 15 '19 at 17:33
  • When it binds the application, it passes the config directory, so that it knows where to load the `bootstrap.php` from. This all looks exactly right. With your server's document root pointed to the `webroot` folder, is it still not working? And if not, please include some more detail about what "not working" means, and be sure that you have `debug` set to true in your `config/app.php` so that you are getting maximal error reporting. – Greg Schmidt Feb 15 '19 at 17:41
  • I added images of the sidebar that's not loading. To be more accurate, it looks like some of the content is loading, but the left sidebar is not correct. It just shows some default stuff from `vendor/`, but it should show the sidebar that I see in the live app in _myteamconnector.com_. `debug` is set to true in my `config/app.php`. Sorry for not understanding everything here. – Pete Feb 15 '19 at 17:47
  • You'll need to find the place in your code that is adding the sidebar. It's probably under `src/Template/Layout/default.ctp`, though it could be `vendor/maiconpinto/src/Template/Layout/default.ctp`. There are many ways to do this, so many ways to get it wrong. Seeing your env and config doesn't really help with resolving it, though, and all that may just turn off people who might otherwise help. – Greg Schmidt Feb 15 '19 at 17:55
  • Thanks! I'll look into this stuff and post when I know more. – Pete Feb 15 '19 at 23:08
  • So, seems like the most important piece of info is that my coworker is using an identical sandbox of the repo and the same MAMP version and settings and his works. So it must be some configuration in the system that differs? – Pete Mar 08 '19 at 11:29

1 Answers1

0

SOLVED The issue was that the composer.json file was specifying "maiconpinto/cakephp-adminlte-theme": "^1.0" and therefore installing v1.1.0 which requires different implementations depending on the cakephp version being < or >=3.5. So specifying "maiconpinto/cakephp-adminlte-theme": "1.0.8" in the composer.json file installed the previous version, which is compatible with the implementation in my repo. For some reason in the working version there was a mismatch between the composer.json file and the vendor folder (i.e. the vendor folder contained a bunch of plugins that the composer.json file didn't have) allowing everything to work as long as you didn't run composer update, which my coworker hadn't done.

Pete
  • 1
  • 3