Why won't Namespaces Work in a PHP required file? [duplicate]PHP namespaces and requireWhy is “using namespace std;” considered bad practice?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?Does PHP namespace autoloading have to use folders?Why “no such file or directory … autoload.php” when accessing Laravel app?PHP Custom Namespace not workingWarning: require(vendor/autoload.php): failed to open stream: No such file or directory in php with mongoDB :php artisan serve error : require(): Failed openingPHP Fatal error: require(): Failed opening required
Hard for me to understand one tip written in "The as-if rule" of cppreference
Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?
Listen to my Story...Let us find the Unique Invisible Pan Digital Pair
Subset of knight's move in chess.
What are the children of two Muggle-borns called?
What was the point of separating stdout and stderr?
Why was Pan Am Flight 103 flying over Lockerbie?
Is it OK to throw pebbles and stones in streams, waterfalls, ponds, etc.?
Correct use of the the idiom 'Гнать/Катить бочку'
Could you fall off a planet if it was being accelerated by engines?
How can an inexperienced GM keep a game fun for experienced players?
Customs and immigration on a USA-UK-Sweden flight itinerary
Did the Russian Empire have a claim to Sweden? Was there ever a time where they could have pursued it?
What does 'in attendance' mean on a death certificate - England?
Example of query execution plan where the cardinality estimation makes a difference
Is my guitar action too high or is the bridge too high?
How far can gerrymandering go?
Why didn't Caesar move against Sextus Pompey immediately after Munda?
Fully submerged water bath for stove top baking?
Fast method to cut/shred glue stick into small pieces
Delete all files from a folder using a bat that match a certain pattern in Windows 10
Tricolour nonogram
Meaning of the word "good" in context
Why is numpy sometimes slower than numpy + plain python loop?
Why won't Namespaces Work in a PHP required file? [duplicate]
PHP namespaces and requireWhy is “using namespace std;” considered bad practice?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?Does PHP namespace autoloading have to use folders?Why “no such file or directory … autoload.php” when accessing Laravel app?PHP Custom Namespace not workingWarning: require(vendor/autoload.php): failed to open stream: No such file or directory in php with mongoDB :php artisan serve error : require(): Failed openingPHP Fatal error: require(): Failed opening required
This question already has an answer here:
PHP namespaces and require
1 answer
This question may sound stupid to many of you, still have I been unable to find any clue in the docs (I did RTFM).
When you set a php variable in a php file and then make use of it in a file you required, it totally works.
But today, While trying to do the same with namespaces, I was getting an unexpected error.
In the main php file :
include("./scripts/proj4php/vendor/autoload.php");
use proj4phpProj4php;
use proj4phpProj;
use proj4phpPoint;
// Initialise Proj4
$proj4 = new Proj4php();
require './functions/myfile.php';
in myfile.php :
$pointDest = $proj4->transform($projWGS84, new Point($r['coord_x'], $r['coord_y'], $projL2e));
This last lane was throwing an Undefined Point class error while it's perfectly fine if I put the line in the main php file.
Both $proj4 and Point() have been set in the main php file, but only the $proj4 was fine in the required php file.
How comes ? What's the logic here ?
Thank you all for your help !
php class namespaces require
marked as duplicate by Nick
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 25 at 23:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
PHP namespaces and require
1 answer
This question may sound stupid to many of you, still have I been unable to find any clue in the docs (I did RTFM).
When you set a php variable in a php file and then make use of it in a file you required, it totally works.
But today, While trying to do the same with namespaces, I was getting an unexpected error.
In the main php file :
include("./scripts/proj4php/vendor/autoload.php");
use proj4phpProj4php;
use proj4phpProj;
use proj4phpPoint;
// Initialise Proj4
$proj4 = new Proj4php();
require './functions/myfile.php';
in myfile.php :
$pointDest = $proj4->transform($projWGS84, new Point($r['coord_x'], $r['coord_y'], $projL2e));
This last lane was throwing an Undefined Point class error while it's perfectly fine if I put the line in the main php file.
Both $proj4 and Point() have been set in the main php file, but only the $proj4 was fine in the required php file.
How comes ? What's the logic here ?
Thank you all for your help !
php class namespaces require
marked as duplicate by Nick
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 25 at 23:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
What is the namespace for yourPoint
class?
– Script47
Mar 25 at 15:46
add a comment |
This question already has an answer here:
PHP namespaces and require
1 answer
This question may sound stupid to many of you, still have I been unable to find any clue in the docs (I did RTFM).
When you set a php variable in a php file and then make use of it in a file you required, it totally works.
But today, While trying to do the same with namespaces, I was getting an unexpected error.
In the main php file :
include("./scripts/proj4php/vendor/autoload.php");
use proj4phpProj4php;
use proj4phpProj;
use proj4phpPoint;
// Initialise Proj4
$proj4 = new Proj4php();
require './functions/myfile.php';
in myfile.php :
$pointDest = $proj4->transform($projWGS84, new Point($r['coord_x'], $r['coord_y'], $projL2e));
This last lane was throwing an Undefined Point class error while it's perfectly fine if I put the line in the main php file.
Both $proj4 and Point() have been set in the main php file, but only the $proj4 was fine in the required php file.
How comes ? What's the logic here ?
Thank you all for your help !
php class namespaces require
This question already has an answer here:
PHP namespaces and require
1 answer
This question may sound stupid to many of you, still have I been unable to find any clue in the docs (I did RTFM).
When you set a php variable in a php file and then make use of it in a file you required, it totally works.
But today, While trying to do the same with namespaces, I was getting an unexpected error.
In the main php file :
include("./scripts/proj4php/vendor/autoload.php");
use proj4phpProj4php;
use proj4phpProj;
use proj4phpPoint;
// Initialise Proj4
$proj4 = new Proj4php();
require './functions/myfile.php';
in myfile.php :
$pointDest = $proj4->transform($projWGS84, new Point($r['coord_x'], $r['coord_y'], $projL2e));
This last lane was throwing an Undefined Point class error while it's perfectly fine if I put the line in the main php file.
Both $proj4 and Point() have been set in the main php file, but only the $proj4 was fine in the required php file.
How comes ? What's the logic here ?
Thank you all for your help !
This question already has an answer here:
PHP namespaces and require
1 answer
php class namespaces require
php class namespaces require
asked Mar 25 at 15:40
Vincent MonteilVincent Monteil
3553 silver badges19 bronze badges
3553 silver badges19 bronze badges
marked as duplicate by Nick
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 25 at 23:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Nick
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 25 at 23:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
What is the namespace for yourPoint
class?
– Script47
Mar 25 at 15:46
add a comment |
What is the namespace for yourPoint
class?
– Script47
Mar 25 at 15:46
What is the namespace for your
Point
class?– Script47
Mar 25 at 15:46
What is the namespace for your
Point
class?– Script47
Mar 25 at 15:46
add a comment |
1 Answer
1
active
oldest
votes
You created an alias in the main.php file for proj4phpPoint
, but that alias does not extend to other files since it is resolved at compile time, not runtime.
You need to alias/import the class in the file where it is used. I honestly see no point in importing Point in main.php if you don't use it there.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You created an alias in the main.php file for proj4phpPoint
, but that alias does not extend to other files since it is resolved at compile time, not runtime.
You need to alias/import the class in the file where it is used. I honestly see no point in importing Point in main.php if you don't use it there.
add a comment |
You created an alias in the main.php file for proj4phpPoint
, but that alias does not extend to other files since it is resolved at compile time, not runtime.
You need to alias/import the class in the file where it is used. I honestly see no point in importing Point in main.php if you don't use it there.
add a comment |
You created an alias in the main.php file for proj4phpPoint
, but that alias does not extend to other files since it is resolved at compile time, not runtime.
You need to alias/import the class in the file where it is used. I honestly see no point in importing Point in main.php if you don't use it there.
You created an alias in the main.php file for proj4phpPoint
, but that alias does not extend to other files since it is resolved at compile time, not runtime.
You need to alias/import the class in the file where it is used. I honestly see no point in importing Point in main.php if you don't use it there.
answered Mar 25 at 15:49
DevonDevon
24.6k4 gold badges29 silver badges54 bronze badges
24.6k4 gold badges29 silver badges54 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
What is the namespace for your
Point
class?– Script47
Mar 25 at 15:46