简体   繁体   English

“找不到对象!”OSX,Silex和XAMPP开发环境

[英]“Object Not Found!” OSX, Silex and XAMPP development environment

I have been struggling with setting up a PHP/MySQL environment all day and thought I would finally ask for help. 我一直在努力建立一个PHP / MySQL环境,并且认为我最终会寻求帮助。

I have XAMPP up and running. 我有XAMPP启动并运行。 In order to work in my preferred directory I've updated /Applications/XAMPP/xamppfiles/etc/httpd.conf with: 为了在我的首选目录中工作,我更新了/Applications/XAMPP/xamppfiles/etc/httpd.conf

User MY_USERNAME

...

DocumentRoot "/Users/PATH/TO/WORKING/DIR/web"
<Directory "/Users/PATH/TO/WORKING/DIR/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/trunk/mod/core.html#options
    # for more information.
    #
    #Options Indexes FollowSymLinks
    # XAMPP
    Options Indexes FollowSymLinks ExecCGI Includes

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    # since XAMPP 1.4:
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

Otherwise my httpd.conf settings are the XAMPP defaults. 否则我的httpd.conf设置是XAMPP默认值。 In my web dir, I have index.php: 在我的web目录中,我有index.php:

<?php

require_once __DIR__."/../vendor/autoload.php";

$app = new Silex\Application();

$app->get("/", function () {
    return "Hello World";
});

$app->get("/test", function () {
    return "Success";
});

$app->run();

?>

If I go to localhost , I get the expected "Hello World." 如果我去localhost ,我会得到预期的“Hello World”。 However, if I go to localhost/test I get: 但是,如果我去localhost/test我得到:

Object not found! 找不到对象!

The requested URL was not found on this server. 在此服务器上找不到请求的URL。 If you entered the URL manually please check your spelling and try again. 如果您手动输入了URL,请检查拼写,然后重试。

If you think this is a server error, please contact the webmaster. 如果您认为这是服务器错误,请与网站管理员联系。

Error 404 错误404

localhost Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/5.6.24 mod_perl/2.0.8-dev Perl/v5.16.3 localhost Apache / 2.4.23(Unix)OpenSSL / 1.0.2h PHP / 5.6.24 mod_perl / 2.0.8-dev Perl / v5.16.3

This is a much simplified example, but illustrates the problem. 这是一个非常简单的示例,但说明了问题。

I've scoured the Google results for this error, but none of the recommended suggestions have helped: 我已经搜索了Google错误的结果,但是没有一条推荐的建议有所帮助:

  • Lots of people suggest I update .htaccess , but I don't know where that is in XAMPP or where I should create it or what I should put in it or what it is. 很多人建议我更新.htaccess ,但我不知道XAMPP中的位置,或者我应该在哪里创建它或者我应该放入它或它是什么。
  • Recommendation of changing AllowOverride None to AllowOverride All in httpd.conf didn't seem to work. httpd.conf中将AllowOverride None更改为AllowOverride All建议似乎不起作用。 (I reverted this back to the default settings after confirming that it didn't help) (确认它没有帮助后,我将其恢复为默认设置)

Any help would be appreciated! 任何帮助,将不胜感激! Thanks for your time! 谢谢你的时间!

SOLUTION

I had created .htaccess in /Users/PATH/TO/WORKING/DIR/todo where I needed to put it in /Users/PATH/TO/WORKING/DIR/todo/web where I was pointing XAMPP to. 我在/Users/PATH/TO/WORKING/DIR/todo中创建了.htaccess ,我需要将它放在/Users/PATH/TO/WORKING/DIR/todo/web ,我指向XAMPP。 Then inside of .htaccess I put the stuff Silex told me to put in there: http://silex.sensiolabs.org/doc/master/web_servers.html 然后在.htaccess里面我把Silex告诉我的内容放在那里: http//silex.sensiolabs.org/doc/master/web_servers.html

.htaccess needs to be at the root of your web application, so in web . .htaccess需要位于Web应用程序的根目录,因此在web Create it if it doesn't exist. 如果它不存在则创建它。 It should contain what's indicated here http://silex.sensiolabs.org/doc/master/web_servers.html 它应该包含这里指出的内容http://silex.sensiolabs.org/doc/master/web_servers.html

AllowOverride All is indeed needed but if you don't have any .htaccess file in your web app folder, there's 0 chance it's gonna work. 确实需要AllowOverride All ,但如果你的网络应用程序文件夹中没有任何.htaccess文件,那么它将有0次机会运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM