OK, so one simple way would be to edit your template, I assume header.php
for where you want the menu to appear. Use the template include to load myfile.php
get_template_part('template-parts/myfile');
Then inside myfile.php
:
<?php
$search .= '<li class="search"><form role="search" method="get" id="searchform" action="'.home_url( "https://wordpress.stackexchange.com/" ).'"><input type="text" value="search" name="s" id="s" /><input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /></form></li>';
wp_nav_menu(array(
'menu' => 'Menu Name',
'theme_location' => 'menu-name',
'container' => 'nav',
'container_class' => 'main-menu-class',
'container_id' => '',
'items_wrap' => '<ul class="navbar-nav">%3$s'. $search .'</ul>'
));
So your myfile contains the menu as well as the search form. This isn’t tested, but you get the idea – change out the menu name and HTML elements & classes.