Yii - trouble at the beginning - yii

What i did:
Instaled XAMPP (default settings)
Downloaded and instaled newest version of Yii (c:\xampp\htdocs\yii)
Made PATH (;c:\xampp\php)
I did everything what i should in CMD, after that localhost/yii/test is working but when i make new controller and i try go to site localhost/yii/test/bazadanych, then i have 404 error.
(c:\xampp\htdocs\yii\test\protected\controllers\BazadanychController.php)
<?php
class BazadanychController extends CController
{
public function actionIndex()
{
$Polaczenie = Yii::app()->db;
$Zapytanie = $Polaczenie->createCommand('CELECT * FROM osoby');
$DaneZBazy = $Zapytanie->query();
while(($Rekord=$DaneZBazy->read())!==false)
{
echo $Rekord['imie'].'<br>';
}
}
}
?>
Where did i mistake? I read polish book "yiiframework" (Author: Łukasz Sosna, printed this year) and i made step by step so i don't know what is wrong. Any ideas?

Related

Shut the default web page of Apache Aries down

I am using the Apache Aries in karaf. I have setup my homepage in a separate bundle. The problem is that when i stop the 'web-home' bundle of mine, I see the apache aries default page.
In the karaf-logs I see the default page is always called anyway.
"WARN JAXRSUtils - Both org.apache.aries.jax.rs.whiteboard.internal.DefaultWeb#home and my.packet.Home#home are equal candidates for handling the current request which can lead to unpredictable results"
This is how my Home.java looks like:
#Path("/")
#Component(
property = {
JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT + "=(osgi.jaxrs.name=.default)",
JaxrsWhiteboardConstants.JAX_RS_RESOURCE + "=true"
},
service = Home.class
)
public class Home {...
So, how does one configure the Aries to shut its homepage off, or otherwise just prevent this potentially unpredictable result?
I'd be happy to clarify further necessary details if asked. Thanks in advance.
it looks like the DefaultWeb is created by a configuration called default.web at the WhiteBoard class right here:
return OSGi.register(
Application.class,
() -> new DefaultApplication() {
#Override
public Set<Object> getSingletons() {
Object defaultApplication = _configurationMap.get(
"default.web");
if (defaultApplication == null ||
Boolean.parseBoolean(defaultApplication.toString())) {
return Collections.singleton(new DefaultWeb());
}
else {
return Collections.emptySet();
}
}
},
Looking at the bundle activator it looks like that if you set the configuration default.web to false it will disable the Default page.
In order to do that, create or find this file:
.../etc/org.apache.aries.jax.rs.whiteboard.default.cfg
(Which is the default config file of this bundle. As a general rule, the default config file is: ../etc/<Persistent ID of Bundel.cfg)
and add / set this line:
default.web=false

Issue running Symfony 3 on Apache

I have Wamp64 running on my Windows 10 machine.
Localhost set up fine and I can see the Wamp64 home page at Localhost.
I've installed Symfony and followed the instructions as per their website.
I set up "project1" at C:\wamp64\www\project1, it has a public directory with an index.php file in it.
When I browse to http://localhost/project1/public/index.php I get an HTTP 404 error
Error page...
Should be getting the Symfony welcome page.
Any help gratefully received
You need to define a route with the path /
routes.yaml:
home:
path: /
defaults: { _controller: 'AppBundle\Controller\DefaultController::index' }
OR
Annotation:
// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
/**
* Matches / exactly
*
* #Route("/", name="home")
*/
public function index()
{
// ...
}
}
You can also define these with XML and PHP. See the docs.
IF you're using Symfony 4 as suggested in the comments, the namespace is App\Controller and the localtion of your controller is /src/Controller instead of /src/AppBundle/Controller

PHP static context refers to the wrong class

I have some php code in a site that I'm trying to move to a different server (from development into production) similar to the following:
class test1 {
static function make () {
$object = static::maker(function( $params ) {
return new static($params);
});
return $object;
}
protected static function maker ( $callable ) {
$params = [/*...*/];
return $callable( $params );
}
}
class test2 extends test1 {
function sayhi () {
echo "Hello! from: ".get_called_class();
}
}
$test = test2::make();
$test->sayhi();
My development environment is OSX 10.9 running php 5.5.17 and nginx with php-fpm, and my production environment is Ubuntu 14.04.1 LTS running php 5.5.11 and nginx with php-fpm.
on my development machine I get the expected result:
Hello! from: test2
but on the production server it throws an error:
PHP message: PHP Fatal error: Call to undefined method test1::sayhi()
revealing that the static context is pointing to test1 which isn't expected.
The workaround I came up with is to call the function like this:
$class = get_called_class();
$object = static::maker(function( $params ) use ( $class ) {
return new $class($params);
});
My question is: Why is it different between versions? And can someone shed some light on what's the expected behavior?
Thanks!
I found the answer to my question: late static bindings.
https://bugs.php.net/bug.php?id=67774
http://php.net//manual/en/language.oop5.late-static-bindings.php

Piranha CMS Management Custom Controller Not Found

I am having an issue with adding a custom controller to my Piranha CMS.
I have set up a new site and installed from the template and all the base functionality is working well.
I have added the menu to the manager section using the following code from the documentation:
Manager.Menu.Add(new Manager.MenuGroup()
{
InternalId = "MEProducts",
Name = "Products"
});
Manager.Menu.Where(m => m.InternalId == "MEProducts").Single().Items =
new List<Manager.MenuItem>() {
new Manager.MenuItem() {
Name = "Products",
Action = "productlist",
Controller = "products",
Permission = "ADMIN",
SelectedActions = "productlist,productedit"
},
new Manager.MenuItem() {
Name = "Product groups",
Action = "productgrouplist",
Controller = "products",
Permission = "ADMIN",
SelectedActions = "productgrouplist,productgroupedit"
}
};
This menu displays in the manager interface fine, the problem is when I click on the menu item the controller path can not be found.
The controller is class is in Areas/Manager/Controllers/ProductsController.cs and the code is below
namespace MyApp.Areas.Manager.Controllers
{
public class ProductsController : ManagerController
{
//
// GET: /Manager/Products/
public ActionResult Index()
{
return View();
}
public ActionResult ProductList()
{
return View();
}
public ActionResult ProductEdit(string id = "")
{
return View();
}
}
}
There are view files for ProductList and ProductEdit in Areas/Manager/Views/Products/
My web config contains the following line that I believe I need
<add key="manager_namespaces" value="MyApp.Areas.Manager.Controllers" />
When I click on the Products link in the manager I get
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /MyApp/manager/products/productlist
The page /MyApp/manager/page displays fine for the default configuration.
I am sure that I have missed something, or done something incorrect somewhere I'm just not sure where it is.
I've tried reproduce your issues but it works perfectly with your productscontroller in my project. I've zipped my test-project and uploaded it to my dropbox so you can download and compare it to your project:
EDIT
Removed download link as author downloaded the file
Please let me know when you've downloaded the zip-file so I can delete it.
Regards
Håkan

Cannot access RavenDB Management Studio

Try:
I created a new project in VS2012
I installed via the NuGet package RavenDB Embedded -Pre
I installed Ninject.MVC3
Added a module for ninject RavenDB:
Public class RavenDBNinjectModule : NinjectModule
{
public override void Load()
{
Bind<IDocumentStore>().ToMethod(context =>
{
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
var documentStore = new EmbeddableDocumentStore { Url="http://localhost:8080/", DataDirectory="~/App_Data", UseEmbeddedHttpServer = true };
return documentStore.Initialize();
}).InSingletonScope();
Bind<IDocumentSession>().ToMethod(context => context.Kernel.Get<IDocumentStore>().OpenSession()).InRequestScope();
}
}
In my class "NinjectWebCommon" ...
private static void RegisterServices(IKernel kernel)
{
kernel.Load(new RavenDBNinjectModule());
}
When running the application, the following url was generated ("http://localhost:1423")
Verify that the file "Raven.Studio.xap" was the root of my application
I tried accessing "http://localhost:8080" but the following screen is displayed:
What am I doing wrong?
As it turned out, the issue is that documentStore.Initialize never get called, because that no one did ask Ninject to resolve IDocumentStore.
You are setting the Url property, which means that you aren't running in embedded mode, but in server mode.
Remove the Url property, and everything will work for you.
I found the problem!
Since he had used IDocumentSession in no time, the ninject had not created the instance of IDocumentStore and thus not run the Initialize method