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













0
















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 !










share|improve this question













marked as duplicate by Nick php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

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 your Point class?

    – Script47
    Mar 25 at 15:46
















0
















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 !










share|improve this question













marked as duplicate by Nick php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

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 your Point class?

    – Script47
    Mar 25 at 15:46














0












0








0









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 !










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 15:40









Vincent MonteilVincent Monteil

3553 silver badges19 bronze badges




3553 silver badges19 bronze badges




marked as duplicate by Nick php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

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 php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

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 your Point 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






What is the namespace for your Point class?

– Script47
Mar 25 at 15:46











1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer


























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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.






    share|improve this answer



























      1














      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.






      share|improve this answer

























        1












        1








        1







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 15:49









        DevonDevon

        24.6k4 gold badges29 silver badges54 bronze badges




        24.6k4 gold badges29 silver badges54 bronze badges
















            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.





            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현