How to enter localhost url manually ( using xampp php version 7.2) - xampp

I am trying to get into my root i have xampp in my D folder and i have create folder name (app) into my htdocs and created file Book.php now i am trying to access this file using url http://localhost/app/Book.php but no output. can anyone correct me?
class Book // class is where we define properties and methods
{
public $isbn;
public $title;
public $author;
public $available;
//instantiate
$harry_potter = new Book();
$harry_potter->isbn = 322401494;
$harry_potter->title = "Harry Potter and Magicians";
$harry_potter->author = "Shahzad";
$harry_potter->available = 10;
var_dump($harry_potter);

Actually, I can see 2 main reasons for this to happen,
You aren't using the right port, XAMPP might be using another port like 8080 check it out in the settings. If this is right then you should access to your file using localhost:port/book.php
Book.php return nothing, you should post book.php code here so we can figure out where is the problem.
Hope it could help.

Related

Joomla 3 test site vs. production site: which files should change?

I am maintaining a Joomla 3 site, and I want to set up a test site in a different web host, so that we can test code changes in it first. The test web host is in a different server, uses a different DB, etc., but otherwise I want it to be as identical as possible to the production site.
Which files should I pay attention to, when downloading and uploading the site to the other host? I know about configuration.php. Is there anything else?
(All the docs I've found when searching were about older versions of Joomla: 1.5, 2.x...)
Here is another solution which does not involve any third party component. You need to take care of some points though. Steps are explained below.
Copy the entire files from 1st server to 2nd server.
From phpmyadmin copy the database from 1st to 2nd server.
Change the database details and other configuration details in the configuration.php file. Mainly you need to change the database details and the log and tmp path. Check the log and tmp folders are writable.
<?php
class JConfig {
public $db = 'joomla';
public $dbprefix = 's5oiy_';
public $log_path = 'C:/xampp/htdocs/joomla/administrator/logs';
public $memcache_server_host = 'localhost';
public $memcache_server_port = '11211';
public $password = 'dbpass';
public $sendmail = '/usr/sbin/sendmail';
public $smtpauth = '0';
public $smtphost = 'localhost';
public $smtppass = '';
public $smtpport = '25';
public $smtpsecure = 'none';
public $smtpuser = '';
public $tmp_path = 'C:/xampp/htdocs/joomla/tmp';
public $user = 'root';
public $memcached_server_host = 'localhost';
public $memcached_server_port = '11211';
public $redis_server_host = 'localhost';
public $redis_server_port = '6379';
public $redis_server_auth = '';
public $redis_server_db = '0';
public $proxy_enable = '0';
public $proxy_host = '';
public $proxy_port = '';
public $proxy_user = '';
public $proxy_pass = '';
public $session_memcache_server_host = 'localhost';
public $session_memcache_server_port = '11211';
public $session_memcached_server_host = 'localhost';
public $session_memcached_server_port = '11211';
}
?>
These are the variables in configuration.php file that need to be checked once you change the server.
If you dont know the Base directory path you may give wrong log and tmp path. So to know the directory path you can use this code
<?php
$dir = getcwd();
echo $dir;
?>
For things like this I suggest using Akeeba Backup and Kickstart
https://www.akeebabackup.com/products/akeeba-backup.html
https://www.akeebabackup.com/products/akeeba-kickstart.html
Just create a backup of your site and use Kickstart to install it on your test server. The install process will take care of the different settings. Make sure you disable sending mails from the test system. Otherwise your users might get mails the should not get.
Sven's suggestion is great, here are a couple of other options.
There might be some advantages to creating your test site on the same server as your production site, for one thing, you'll know that the server environment will be the same. Here are 2 ways you could do this.
You could create a new 'test' subdirectory on your production site and use Akeeba backup to install a copy of your site in that location. If you do this, take care to create a second test database and specify this new database when you use Akeeba backup. When you are finished your production site will be at www.domain.com and your test site will be at www.domain.com/test/
Alternatively StageIt is a very good commercial plugin which will setup a staging environment on your production server. You can test your ideas and sync them back from the test to the production site when you are finished.
Good luck!

How we setup cakephp without database?

In few project we don't need database, so how we setup cakephp on local machine without modification in database config? Right now what I done ...I created database and modified config file. But my database has no table, its just wastage of database....so please suggest better way to do this.
Thank you in advance..
With CakePHP 2.3.x I simply use an empty string as a datasource in the database configuration and it works fine.
The database configuration (app/Config/database.php) is almost empty, it looks like this:
class DATABASE_CONFIG {
public $default = array(
'datasource' => '',
);
}
You have to tell your AppModel not to use DB tables, otherwise you'll get an error: "Datasource class could not be found". It's not enough to set the $useTables in descendant models only.
class AppModel extends Model {
public $useTable = false;
}
I dindn't experienced any problems with that yet.
Cakephp actually try to connect to a database no matter that you don’t use a table
so using this
class MyModel extends AppModel {
public $useTable = false;
}
it will be just a mistake , creating application on cakephp is piece of cake. Here are some steps you have to do in order to start developing without a database.
Create fake dbo source
Create file DboFakeDboSource.php in app/Model/Datasource/Dbo/ and put the following code in it
class DboFakeDboSource extends DboSource {
function connect() {
$this->connected = true;
return $this->connected;
}
function disconnect() {
$this->connected = false;
return !$this->connected;
}
}
Set the default connection
The next step is to tell cakephp to use dbo source by default. Go and change default connection in database.php to be like this
var $default = array(
'driver' => 'FakeDboSource'
);
Fine tuning the model
The third step is to be sure that $useTable = false; is included in every model, so add it in AppModel.php
You can just leave default datasourse settings empty in database.php and for Models you use, specify that it doesn't need corresponding table in DB like following:
class MyModel extends AppModel {
public $useTable = false;
}

Beginners Tutorial for Zend Framework implementing model and call it from Controller

I'm quite new to ZF, and right now, i try to write a tiny app, based on ZF. It works more or less fine until now. I wanna access my db- data. For starters, i just want to use query-string, before I start messing araound with zend_db. So to keep a nice mvc-structure, I created application/models/IndexMapper.php
class Application_Models_IndexMapper{...}
it just contains one function by now to see if it works
public function test(){
return ('yay');
}
In my IndexController, which is working, i try to access my model by
$indexMapper = new Application_Models_IndexMapper();
$x = $indexMapper->test();
but the first line throws an
Fatal error: Class 'Application_Models_IndexMapper' not found in /path/to/application/controllers/IndexController.php on line 31
As I'm new, I don't understand the more complex tutorials and they don't help me fix my problem. What am I doing wrong? Do I have to include it somehow?
Thanks
edit: my application/bootstrap.php
<?php
defined('APPLICATION_PATH')
or define('APPLICATION_PATH' , dirname(__FILE__));
defined('APPLICATION_ENVIRONMENT')
or define('APPLICATION_ENVIRONMENT' , 'development');
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
$frontController->setParam('env', APPLICATION_ENVIRONMENT);
Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
//Doctype
$view = Zend_Layout::getMvcInstance()->getView();
$view->doctype('HTML5');
$view->addHelperPath('App/View/Helper', 'App_View_Helper');
unset($frontController);
The structure for a model would be found under ./application/models/IndexMapper.php. In that file you would have the class As you named it and then the autoloading will work.
A great beginner tutorial would be found on www.akrabat.com
You have your class in the wrong place and have named it incorrectly.
Your class should be in application/models/Indexmapper.php and should look like this:-
class Application_Model_Indexmapper
{
public function test(){
return ('yay');
}
}
Then you call it thus:-
$indexMapper = new Application_Model_Indexmapper();
$x = $indexMapper->test();
Notice I dropped the 's' from the end of Models, it is not required and will cause an error as you found. Also the class is in the models folder, not modules. If you want to use modules then you need to read this and this from the manual.
Your bootstrap.php should look like this for a first, basic project:-
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
//Yes, it's empty!
}
Well, I guess my tutorial wasn't very helpful. I'll do as recommended, and start over from scratch. Thanks though

How to read images from a remote sftp file server

So I'm using CodeIgniter PHP Framework for a website. We have a few servers, a live, a dev, and a file server. We've successfully been able to upload files to our dev server, and then secure copy them to our file server for storage. Our problem now is a way to read/display the images on our dev website from the file server. Our file server uses sftp for it's security. We've been looking into different ways to just pass back an image object from the file server, but not actually the actual file. Any suggestions on how to do this? Thanks.
CodeIgniter PHP Framework
Linux Servers
SFTP on the file server
Thanks...
Well, I have not dealed with sftp so much but at lest I will try to give you some steps to begin.
You need install some apache/php module like ssh2 and enable it with extension=php_ssh2.dll.
You could make your own sftp library, like this:
class Sftp{
protected $connection;
public function __construct($params)
{
}
public function connect()
{
$server = "you-server.com";
$port = "1234";
$username = "admin";
$password = "blabla";
//connect
$ssh2 = ssh2_connect($server, $port);
if(ssh2_auth_password($ssh2, $username, $password))
{
//sftp session
$this->connection = ssh2_sftp($resConnection);
}
else
{
echo "Unable to connect to server";
}
}
public function download($image_name)
{
$image = fopen("ssh2.sftp://{$this->connection}/path/to/{$image_name}", 'r');
fclose($image);
}
}
And then try to use it like:
$this->sftp->connect();
$image = $this->sftp->download('image-name');
I found this Codeigniter library on Github. I haven't used it yet but it seems like you need to do several steps before you could use load the library using Codeigniter. Otherwise this looks promising.
https://github.com/ipolar/CodeIgniter-sFTP-Library

Can the subdomain URL segment be used as a class in Codeigniter?

I need to use a subdomain as a class. ie, instead of:
www.example.com/class/function/ID eg www.example.com/town-name/history/1
I need
class.example.com/function/ID eg town-name.example.com/history/1
I've wildcarded the subdomain in nginx, now I've googled and read
http://codeigniter.com/user_guide/libraries/uri.html
http://codeigniter.com/user_guide/general/urls.html
http://codeigniter.com/user_guide/helpers/url_helper.html
but nothing relevant. I need it to be so that if another town is added to the db, it'll resolve that new town and its details.
I see many discussions about rewrites, redirects etc, but I specifically need to use the subdomain town name as the class variable. If possible, in an idea world, I could use both together, but I doubt that's possible?
I've had it going fine in plain old php for a couple of years now; now I want to upgrade to codeigniter without ruining my old structure if possible (plus there's a good reason for it).
Thanks you.
You can do it. I'm doing it for one of my projects.
In the constructor of your controller, just explode the current url and get the subdomain and pass it in your method as a variable
public class Controller extends CI_Controller {
$subdomain = null;
public __construct()
{
// explode url here and set $this->subdomain = the actual subdomain
}
public function index()
{
if($this->subdomain == null) {
show_404();
} else {
// do what you wish
}
}
}

Resources