Welcome Guest, Not a member yet? Register   Sign In
Build your first application
#1

(This post was last modified: 07-31-2020, 12:26 PM by pdos.)

While following the Build the first application -> https://codeigniter.com/user_guide/tutor...pages.html --Static pages. Behavior is different then what is documented:

localhost:8080/pagesĀ  --> http://localhost/ci-news/public/

For each URL listed in Documentation, I have to specify public otherwise it doesn't work. How to remove the requirement to always put public in for the documentation to work?

**Not executing php spark serve as I am running xampp.

Files are located under /htdocs/ci-news.

Moreover, as soon as I add the routesĀ $routes->get('(:any)', 'Pages::view/$1'); in app/Config/Routes.php it starts giving the 404 not found errors.

----Pages controller------
<?php namespace App\Controllers;

use CodeIgniter\Controller;

class Pages extends Controller
{
public function index()
{
return view('welcome_message');
}

public function view($page = 'home')
{
if ( ! is_file(APPPATH.'/Views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
}

$data['title'] = ucfirst($page); // Capitalize the first letter

echo view('templates/header', $data);
echo view('pages/'.$page, $data);
echo view('templates/footer', $data);
}
}
-------------------
Thanks,
Reply


Messages In This Thread
Build your first application - by pdos - 07-31-2020, 12:24 PM
RE: Build your first application - by jreklund - 08-01-2020, 06:01 AM
RE: Build your first application - by pdos - 08-01-2020, 07:52 AM
RE: Build your first application - by jreklund - 08-01-2020, 08:22 AM
RE: Build your first application - by pdos - 08-01-2020, 08:44 AM
RE: Build your first application - by jreklund - 08-01-2020, 09:50 AM
RE: Build your first application - by pdos - 08-01-2020, 10:25 AM
RE: Build your first application - by jreklund - 08-01-2020, 11:03 AM
RE: Build your first application - by pdos - 08-01-2020, 12:16 PM
RE: Build your first application - by InsiteFX - 08-02-2020, 04:07 AM
RE: Build your first application - by pdos - 08-02-2020, 10:47 AM
RE: Build your first application - by jreklund - 08-02-2020, 10:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB