# BasketsController could not be found

**URL:** <https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519>\
**Category:** Need Help\
**Created:** [July 9, 2021, 6:55am UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519 "2021-07-09T06:55:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 9, 2021, 6:55am UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/1 "2021-07-09T06:55:11Z")

</div>

Hello

That [web site](http://www.sogemat.ch/articles/index/1) has been build some years ago and the web site has always been working since the web hosting get some issue.  
The hosting problem was solved but I have a trouble and I never change any controller.

Inspite of this, I have now an issue

```auto

Action BasketsController: could not be found

```

This happen, when I want to add an item into the basket. When I select a number of itemp and then I press the icon  
 ![Screenshot 2021-07-09 at 22.15.46](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/d/de6e9c6d97a534e59d9592c959c9c11a41c6793a.png)

The error

> Action BasketsController::www.sogemat.ch() could not be found

is printed. I observer that is url is

> [http://www.sogemat.ch/baskets/www.sogemat.ch](http://www.sogemat.ch/baskets/www.sogemat.ch)

The last string www.sogemat.ch, should not be there. If you remove the last string ‘www.sogemat.ch’, you can access the basket

In my BasketsController.php, I have this

```auto
	function basketAdd(){
# $data = array('error'=>true);
		$data = current($this->request->data);
		//debug($data);

		if(empty($data['id'])){
			$this->Session->setFlash("No ID",'notif',array('type'=>'danger'));
# $data['message']= "No ID";
		}elseif(empty($data['numberof']) OR $data['numberof']==0){
			$this->Session->setFlash(__("Le nombre d'article ne doit pas être vide ou plus grand que zéro"),'notif',array('type'=>'danger'));
		}else{
			$this->loadModel('Article');
			$this->Article->id = $data['id'];
			$art = $this->Article->find('first',array('conditions'=>array('id'=>$data['id'])));
			if(empty($art)){
# $data['message'] = "That article does not exist";
				$this->Session->setFlash("That article does not exist",'notif',array('type'=>'danger'));
			}else{
				$this->Session->write('Basket.'.$data['id'],$data['numberof']);
				#$this->Session->write('Baskettot.'.$data['id'],$data['numberof']);
				//debug($this->Session->read('basket'));
# $data['message'] = "The product (".$id.") has been add to your basket";
# $data['error']= false;
// $this->Session->setFlash("The product (".$id.") has been add to your basket",'notif');

			}
	
		}
# $this->set('_serialize', $data);
# echo json_encode($json);

		$this->redirect($this->referer());
		
	}

```

The HTML form is as the following

```auto
   <div class="col-xs-6 col-sm-6 col-md-6">
                <?php if($this->Session->read('Arti.basketstatus')){ ?>  
                 
                    <?php echo $this->Form->create(null, array(
                        'url' => array(
                            'controller' => 'baskets', 
                            'action' => 'basketAdd'
                            ),
                        'style'=>'padding:0px;',
                        'id'=>'AddBasket'.$v['id'],
                        'inputDefaults' => array(
                            'label' => false,
                            'div' => false
                            )
                        )); 
                    ?>
            
                        <?php echo $this->Form->input('id',array('id'=>$v['id'],'label'=>null,'type'=>'hidden','value'=>$v['id'] )); ?>
                        <?php echo $this->Form->input('numberof',array('id'=>'numberOf'.$v['id'],'label'=>false,'type'=>'number','class'=>'numberof','style'=>'','value'=>1)); ?>
            </div>
            <div class="col-xs-6 col-sm-6 col-md-6">

                    <?php 
                    $options = array(
                        'label' => '',
                        'div' => false,
                        'class'=>'addToBasket'
                    );
                    echo $this->Form->end($options);
                    ?>
                <?php } ?>    

                </div>
            </div>

```

Why? Why the string www.sogemat.ch is added after /baskets/ ?  
It should not

Many thanks for your help

---

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 9, 2021, 10:45pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/2 "2021-07-09T22:45:33Z")

</div>

Apparently, when I add an item, after the issue the item is add to the basket.  
At the right site, the basekt box show an item.

If you click on Checkout, the items is/are listed.

If you try to delete an item, the problem occur again. It look to be an problem with the forms

---

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 11, 2021, 1:46pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/3 "2021-07-11T13:46:01Z")

</div>

Someone could help me with this issue, I have no idea how to solve it and I I have to go ahead. Many thanks

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 11, 2021, 3:40pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/4 "2021-07-11T15:40:01Z")

</div>

What’s your baseUrl setting?

---

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 11, 2021, 7:19pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/5 "2021-07-11T19:19:31Z")

</div>

Dear Zuluru  
Thanks a lot for your reply and sorry to respond later. I was not available the last 3 hours.

To be honnest, it’s a long time, I have not work on that web site. I hope a provide you the right answer.

In the file ‘core.php’, I have this (commented)

```auto
/**
 * To configure CakePHP *not* to use mod_rewrite and to
 * use CakePHP pretty URLs, remove these .htaccess
 * files:
 *
 * /.htaccess
 * /app/.htaccess
 * /app/webroot/.htaccess
 *
 * And uncomment the App.baseUrl below:
 */
	//Configure::write('App.baseUrl', env('SCRIPT_NAME'));

/**

```

my htaccess file at root is

```auto
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^$ app/webroot/ [L]
   RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

```

my htaccess file at app/ is

```auto
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ webroot/ [L]
    RewriteRule (.*) webroot/$1 [L]
</IfModule>

```

my htaccess file at webroot/ is

```auto
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

```

In my route.php file, I have

```auto
Router::parseExtensions('rss');

	Router::connect('/', array('controller' => 'pages', 'action' => 'index', 'home'));
	//Router::connect('/page/:slug-:id',array('controller'=>'pages','action'=>'show'),array('pass'=>array('id','slug'),'id'=>'[0-9]+','slug'=>'[a-z0-9\-]+'));
	Router::connect('/:slug-:id.html',array('controller'=>'pages','action'=>'show'),array('pass'=>array('id','slug'),'id'=>'[0-9]+','slug'=>'[a-z0-9\-]+'));
	Router::connect('/article/:slug-:id',array('controller'=>'articles','action'=>'show'),array('pass'=>array('id','slug'),'id'=>'[0-9]+','slug'=>'[a-z0-9\-]+'));
	Router::connect('/categorie/:slug',array('controller'=>'articles','action'=>'category'),array('pass'=>array('slug'),'slug'=>'[a-z0-9\-]+'));
	Router::connect('/tag/:name',array('controller'=>'articles','action'=>'tag'),array('pass'=>array('name'),'name'=>'[A-Za-z][a-z0-9\-]+'));

```

But as I say, I never changed any things and the web site was always working since the hosting got server problem which is now solved.

I hope you can help

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 11, 2021, 8:07pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/6 "2021-07-11T20:07:09Z")

</div>

What version of Cake is this app built on? And did the hosting problem fix involve any change in PHP version? And how comfortable / familiar are you with debugging PHP scripts?

---

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 11, 2021, 8:53pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/7 "2021-07-11T20:53:35Z")

</div>

Hello, I have an old version 2.4.2.  
I am not very sure about the PHP version, I have to check.  
Yes, I am used to use PHP, but some doubt about debuging php with CakePHP

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 12, 2021, 12:39am UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/8 "2021-07-12T00:39:31Z")

</div>

I never used v2.x, so I don’t have any concrete things to try. You’ll want to look at what function is being used to generate those links (`$this->Html->link` or the like?), then look at that function, and put some debugging in it to see where it’s going wrong. That should pretty quickly point you at what bit of configuration or environment it’s looking at and making the wrong determination from.

---

<div class="post-metadata">

**Author:** ![pierrot10](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@pierrot10](https://discourse.cakephp.org/u/pierrot10)\
**Post date:** [July 12, 2021, 5:53am UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/9 "2021-07-12T05:53:00Z")

</div>

Ok, thanks,

HOw can debug this line

`$this->redirect($this->referer());`

It look to be the gulty.

Other the things I do not understand, If I decommented the line

‘debug($data);’

noting is printed

```auto
function basketAdd(){
# $data = array('error'=>true);
		$data = current($this->request->data);
		//debug($data);

		if(empty($data['id'])){
			$this->Session->setFlash("No ID",'notif',array('type'=>'danger'));
# $data['message']= "No ID";
		}elseif(empty($data['numberof']) OR $data['numberof']==0){
			$this->Session->setFlash(__("Le nombre d'article ne doit pas être vide ou plus grand que zéro"),'notif',array('type'=>'danger'));
		}else{
			$this->loadModel('Article');
			$this->Article->id = $data['id'];
			$art = $this->Article->find('first',array('conditions'=>array('id'=>$data['id'])));
			if(empty($art)){
# $data['message'] = "That article does not exist";
				$this->Session->setFlash("That article does not exist",'notif',array('type'=>'danger'));
			}else{
				$this->Session->write('Basket.'.$data['id'],$data['numberof']);
				#$this->Session->write('Baskettot.'.$data['id'],$data['numberof']);
				//debug($this->Session->read('basket'));
# $data['message'] = "The product (".$id.") has been add to your basket";
# $data['error']= false;
// $this->Session->setFlash("The product (".$id.") has been add to your basket",'notif');

			}
	
		}
# $this->set('_serialize', $data);
# echo json_encode($json);

		$this->redirect($this->referer());
		
	}

```

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 12, 2021, 2:16pm UTC](https://discourse.cakephp.org/t/basketscontroller-could-not-be-found/9519/10 "2021-07-12T14:16:41Z")

</div>

`debug` only generates output if you’ve got debugging enabled in the config.
