Issue running Symfony 3 on Apache - 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

Related

Failed to load Resource : the server ressponded with the status 404(Not Found) in console in Angular 5

This is quiz.service.ts
import { Injectable, } from '#angular/core';
import { HttpClient } from '#angular/common/http';
#Injectable()
export class QuizService
{
readonly rootUrl = 'http://localhost:4200';
constructor(private http : HttpClient)
{
}
insertParticipant(name: string, email: string)
{
var body = {
Name : name,
Email: email
}
return this.http.post(this.rootUrl + '/api/InsertParticipant',body);
}
}
I get this error:
Failed to load Resource : the server responded with the status 404(Not Found) in console in Angular 5
I think its the url issue is there.
My angular version details
Angular CLI : 1.7.4
Node : 12.13.0
OS : win32 * 64
Angular : 5.2.11
I think the url is having the navigation problem.
How to solve the error?
What is the proper way to route the url in angular 5.2?
as I can see you don't have backend and try to send a requests into your .ts file (mayby I'm wrong).
But if it's true, you need a server with backend api to make http requests (it can be a server on your local machine or it can be remote server) and you need a method that will process your request.
Request will be look like this your_server_url/api/insert_participant.
Also you can you use https://www.npmjs.com/package/angular-in-memory-web-api to emulate CRUD operations without servers api. It intercepts Angular Http and HttpClient requests that would otherwise go to the remote server and redirects them to an in-memory data store that you control.

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

Laravel 5.5 - After upgrading auth is not redirecting properly

I just upgraded my application from Laravel 5.4 to v 5.5. Non authenticated users are not redirecting properly now.
Normally a non authenticated user should be redirected to /manage/login but it is redirected to /login route.
Everything was working perfect in Laravel v 5.4
My app contain two guards.
Routing in web.php
Auth::routes();
Route::middleware(['auth:manager'])->group(function () {
Route::get('/manage', 'Manage\AdminController#dashboard')->name('manage.home');
});
So before upgrade a non authenticated user trying to access /manage was redirected to /manage/login but after upgrading it is redirecting to /login.
I have Auth Controllers copied and modified as needed in Manage\Auth.
Similarly Views are in folder structure Manage\Auth.
My LoginController in Controllers\Manage\Auth
|
Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* #var string
*/
protected $redirectTo = '/manage/';
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function showLoginForm()
{
return view('manage.auth.login');
}
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->flush();
$request->session()->regenerate();
return redirect('/manage');
}
protected function guard()
{
return Auth::guard('manager');
}
I faced the same problem, and it's quit simple to solve.
the point is that if you are using guards you were probably handling unauthenticated exception in your app/Exceptions/Handler.php . when using laravel 5.4 .
After update to 5.5 this is done under vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php .
You should refer to this Laravel 5.5 change unauthenticated login redirect url for more details about how to solve it.

Codeception 2.2 api tests ZF2 and PhpBrowser module together

Codeception API tester require PhpBrowser module and I want to use ZF2 module because I need retrieve some services from ServiceManager.
After update Codeception to 2.2 it throws this exception:
[Codeception\Exception\ModuleConflictException] ZF2 module conflicts
with PhpBrowser
Is there any way to enable ZF2 and PhpBrowser together in Codeception 2.2?
If you have a good reason to use ZF2 in the same suite as PhpBrowser,
you can create your own helper class and load ZF2 module as a dependency.
Configuration:
modules:
enabled:
- PhpBrowser:
url: http://localhost/
- \Helper\Zf2Helper:
depends: ZF2
Code tests/_support/Helper/Zf2Helper.php:
<?php
namespace Helper;
class Zf2Helper extends \Codeception\Module
{
private $zf2;
public function _inject(\Codeception\Module\ZF2 $zf2)
{
$this->zf2 = $zf2;
}
public function doSomethingWithZf2
{
$this->zf2->doSomething();
}
}
Update:
Since Codeception 2.2.2 release it is possible to load services part of ZF2 which enables grabServiceFromContainer method.
Configuration:
modules:
enabled:
- PhpBrowser:
url: http://localhost/
- ZF2
part: services
Thank your for your answer.
Working code with some improvements:
<?php
namespace Helper;
use Codeception\Lib\Interfaces\DependsOnModule;
class Zf2Helper extends \Codeception\Module implements DependsOnModule
{
protected $dependencyMessage = <<<EOF
Example configuring ZF2Helper as proxy for ZF2 module method grabServiceFromContainer.
--
modules:
enabled:
- \Helper\ZF2Helper:
depends: ZF2
--
EOF;
private $zf2;
public function _inject(\Codeception\Module\ZF2 $zf2)
{
$this->zf2 = $zf2;
}
public function _depends()
{
return ['Codeception\Lib\ZF2' => $this->dependencyMessage];
}
public function grabServiceFromContainer($service)
{
return $this->zf2->grabServiceFromContainer($service);
}
}

Yii - trouble at the beginning

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?